Mega Code Archive

 
Categories / C Tutorial / String
 

Strings

A string is nothing more than a character array. All strings end with the NULL character. Use the %s placeholder in the printf() function to display string values. #include <stdio.h> main ( ) {     char *s1 = "abcd";     char s2[] = "efgh";     printf( "%s %16lu \n", s1, s1);     printf( "%s %16lu \n", s2, s2);     s1 = s2;     printf( "%s %16lu \n", s1, s1);     printf( "%s %16lu \n", s2, s2); } abcd 4206592 efgh 2293584