Basic computer course, C programming language, c++ language, online computer coaching

String in C Language – tccicomputercoaching.com

String is a collection of more than one character in C Language.

String-c-Language

In C string is not allowed as a data type,so, we have to use character array.

Declaration string syntax:

charstr_name[size];

Example:

char s1[20];

Input string function:

gets(s1);

To output string function:

puts(s1);

Operations done on the string:

  1. Find out the length of string

strlen(s1)

  1. Copy one string to another string

strcpy(s2,s1)

Here , one s1 string copied to s2 string.

  1. Concate(merge) two string

strcat(s1,s2)

Here , s1 string show concated string (s1+s2). S2 is not changed.

  1. Compare two string

strcmp(s1,s2)

if(strcmp(s1,s2)==0)

{ printf(“both are same”) }

else

{ printf(“both are not same”) }

For more information about String in C Language.

We are Open Online in present days.

Call us @ 9825618292

Visit us @ www.tccicomputercoaching.com

Mail us @ tccicoaching@gmail.com

 

Leave a comment