urgent :: how to break a character string into single characters?
-
Hello to all, i am having a character pointer which points to a character string, lets say it is "char* A", this 'A' points to a character string lets say "Hello codeproject forum", now i want to break this string into single characters so that i can display this string character by character on a page as i am having space limitations means rather than displaying the string "Hello codeproject forum" on one line i want to display it like below- Helloco deproje ctforum how this can be done? can anybody tell me plz? its urgent. Thanks and Regards, Anay
-
Hello to all, i am having a character pointer which points to a character string, lets say it is "char* A", this 'A' points to a character string lets say "Hello codeproject forum", now i want to break this string into single characters so that i can display this string character by character on a page as i am having space limitations means rather than displaying the string "Hello codeproject forum" on one line i want to display it like below- Helloco deproje ctforum how this can be done? can anybody tell me plz? its urgent. Thanks and Regards, Anay
The pointer is basically a pointer to an array of chars. You can simply loop through them one by one and print 7 chars, then print a new line.
char* a = some_string; int length = strlen(a); while(length > 0) { for (int i = 0; i < 7; i++) { length--; cout << *a++; } cout << endl; }