Posted By:
21 Jun, 2013 9:25 am PDT

Strings in C

How can you find the length of a string, concatenate two strings and copy a string without using library functions?
Attachment:None


To find the length of a string we use the function 

for(i=0;a[i]!='\0';i++)

{

    len++;

} 

To copy a string into another string we use the function

for(i=0;a[i]!='\0';i++)

{

    b[i] = a[i];

}

b[i] = '\0';

 

To concatenate two strings into one string we use the function

for(i=0;a[i]!='\0';i++) len++; 

for(j=len,i=0;a[i]!='\0';j++,i++)

{

    a[j] =b[i];

}

 

a[j] = '\0';

Please see the video for more details

Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud