A string is a sequence of zero or more characters enclosed in ‘’ ”.
Example: ‟Welcome to C”
When it is stored in memory, it is stored as an array of characters terminated by a special character called NULL character(‘\0’).This character indicates end of the string.
Our name is a sequence of alphabets. Such a sequence of characters is called a‘string’ in C.
Strings in C
No explicit type, instead strings are maintained as arrays of characters.
Representing strings in C
stored in arrays of characters
array can be of any length
end of string is indicated by a delimiter, the zero character ‘\0’
"A String" A S t r i n g \0
Each character is stored in 1 byte as its ASCII code. Since the string is stored as an array, it is possible to access individual characters. If the starting address is 1000 then the last character i.e.\0 will be stored at address 1008.
Comments
Post a Comment
Please give us feedback through comments