click on this link......

LinkGrand.com

Sunday 31 March 2013

Strings

String Functions
    A string in C is a group of characters that is stored in an array of char and its last character is'\0'
e.g.

char name[10];
name is a character array that can store 10 characters or we call name as a string variable.
To assign a value to a string,
1)
 char name [] = {'c','d','a','c'};
Then internally name contains the string "cdac", with the last character as \0.
2)
 char name[]= "cdac";
3)
To read a string from the keyboard, use
 scanf ("%s", name);
or
 gets(name);
4)
To print a string on the screen, use
 printf("The string is %s",name);
or
 puts(name);

No comments:

Post a Comment