Strings in C++
By admin on May 26, 2009 in Working with C++
Strings and Arrays of characters in C++
Low level strings are represented by arrays of characters in C and C++. These arrays are terminated by ‘\0’ , the special marker character null, which is used to indicate the end of a string.
char string1[ ] = { ‘H’,’e’,’l’,’l’,’o’,’ ‘, ‘W’, ‘o’, ‘r’, ‘l’, ‘d’, ‘\0’ }
The following short program could be used to display string1 :
#include <iostream>
using namespace std;
int main() {
char string1[ ] = { ‘H’,’e’,’l’,’l’,’o’,’ ‘, ‘W’, ‘o’, ‘r’, ‘l’, ‘d’, ‘\0’ } ;
cout << string1 << endl ;
return 0;
}
Sorry, comments for this entry are closed at this time.