C String
Description
String constants consist of text enclosed in double quotes A string is a character array. All strings end with the NULL character.
Example
#include <stdio.h>
/*from w ww .j a v a 2 s . c om*/
int main(void)
{
printf("The character");
return 0;
}
The code above generates the following result.
Example 2
A string is an array of characters.
#include <stdio.h>
/*from w w w .ja v a 2 s. com*/
int main(){
char myname[] = "Dan";
printf("%s \n",myname);
}
The code above generates the following result.
Write string in a more traditional array style
#include <stdio.h>
// w w w.j a va 2s . co m
int main(){
char myname[] = { 'D', 'a', 'n' };
printf("%s \n",myname);
}
The code above generates the following result.