Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Regarding strings (http://www.go4expert.com/forums/regarding-strings-t6215/)

arvind_khadri 5Sep2007 19:26

Regarding strings
hi all....i wanted to know wat is a string(other than being a array of characters,define it in some other way)......then why do we put '\0' at the end of string.....and are there diff types of strings.....

DaWei 5Sep2007 19:42

Re: Regarding strings

myString [] = "This is a string".
That (myString) is a C string. The '\0' at the end (not shown) is there to show the end of the string, since two strings might be contiguous in memory and appear to be one long string without the terminator. I hope this helps, though there seems to be little point in describing it in some way other than an array of characters terminated by zero. That's a perfectly good definition.

The string class available in C++ is another thing entirely.

arvind_khadri 5Sep2007 19:50

Re: Regarding strings
hey thanks...but i wanted to know tat do we have diffreent types of strings in C itself for example like we have *file pointers* nd *function pointers*....

DaWei 5Sep2007 21:44

Re: Regarding strings
A C string is a C string. There is only one kind of 'string', and that is composed of chars. You might say, "I have a long string of integers", and that would be a perfectly good English statement. However, the use of the word "string" does not imply a C entity, merely a verbal communication. You're trying to complicate something that's simple.

All times are GMT +5.5. The time now is 07:32.