Blog
String in C Language – tccicomputercoaching.com
- March 31, 2020
- Posted by: Riddhi Dhandha
- Category: C Programming Langauge at TCCI
String is a collection of more than one character in 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)
2. Copy one string to another string
strcpy(s2,s1)
Here , one s1 string copied to s2 string.
3. Concate(merge) two string
strcat(s1,s2)
Here , s1 string show concated string (s1+s2). S2 is not changed.
4. 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