Reputation: 323
I am reading the book "The C Programming Language" by Brian W. Kernighan and Dennis M. Ritchie.
They talk about "character string" and "string constant". What is the difference between these concepts?
Upvotes: 0
Views: 2892
Reputation: 1688
Check out this link
Upvotes: 2
Reputation: 11377
A string constant is a sequence of characters enclosed in double quotes. A character string is a sequence of characters ending with '\0' stored in a character array or pointed to by a character pointer.
Example:
#include <string.h>
char s[4];
strcpy(s, "foo"); /*"foo" is a string constant and s contains a character string*/
Upvotes: 2
Reputation: 813
string constant: Text enclosed in double quote characters (such as "example" ) is a string constant.
Character String: Strings are actually one-dimensional array of characters terminated by a null character '\0'. So basically the difference is character String is the object and string constant is the way to representation.
Upvotes: 0