I'm just starting out in C++ and the only thing I have had is a High School class about it. I'm making a proram where I need to read each character in a string individually. Is there a way to read character #3 or #4 or whatever in a string and assign that to a variable?
My compiler is Borland C++ BuilderX.
Code Example of what I have so far:
Please excuse any syntax errors as I typed this just now.Code:#include <iostream.h> #include <conio.h> //and include a few other files.... main() { char Words[20], Character; int CharNum; cout << "Enter a few words: "; cin >> Words; /* Now at the end of the string the variable would equal NULL right? */ do { Character = /*Whatever command that sets Character to character number CharNum in the string "Words"*/ //Run a switch statement on that character ++CharNum; } while (Character != NULL); return 0; }
Thanks for reading this