blob: 4030ee09d8b9f396f40a12fb7f54e2f8861dfed8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
//This is the demo function to test a set of string functions
// ascii->converts the input char vector/array to corresponding ascii code or vice versa
// strchr-> it finds the occurence of a charcter in a given string
// strncpy->copy charcters from string
// strspn-> get span of character set in string
function main()
strascii1="ankit is raj"; //This is the input string for testing the function.
asciiout1=ascii(strascii1); //calling of the function
disp(asciiout1);
strascii2=[97 98 99 100 101]; //Input as the ascii code to get converted to string
asciiout2=ascii(strascii2); //calling the function
disp(asciiout2);
str="This is a sample string";
ch="s";
out1=strchr(str,ch);
disp(out1);
ss="Ankit Raj";
nn=5;
resu=strncpy(ss,nn);
disp(resu);
strsample2="Hello this is Ankit";
a="Ank";
oup2=strspn(a,strsample2);
disp(oup2)
endfunction
|