Strings

Any group of characters within double quotation marks is a constant string. Thus a string constant is a one dimensional array of character
eg. "Programming Techniques Using C"
Since the string is enclosed in double quote if we wish to include double quotes in our string we can implement it in the following way with the use of the backslash(\):
"\"Programming Technology Using C\""
We use printf to print the above statement as follows:
printf("\"Programming Techniques Using C\"");
and the output will be:
"Programming Techniques Using C"

A string constant is an array of characters terminated by a null('\0'). A String constant can be initialized as follows:
char str1[]={'P','R','O','G','R','A','M','\0'};

No comments:

Post a Comment