blob: 4033a4fdb5067e3f986f4b1f75483dfe4f09dd29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
// Example 8.3
//Write a program to copy one string into another and count the number
//of characters copied.
//Read data using scanf function
disp("Enter a string:")
[string2]=scanf("%s"); //Read string
l=length(string2); //Compute the length
string1=' '; //string1 is empty
for i=1:l
string1=string1+ part(string2,i);
end
//Printing the results
printf(" %s\n",string1);
printf(" Number of characters = %d\n",l);
|