I don't exactly understand the question, but have you considered using something like boost::tokenizer?
I don't exactly understand the question, but have you considered using something like boost::tokenizer?
A for()
loop is best used when you know (either based on a variable's value, or a set number) how many times a loop should run. For example, if I wanted to have a message printed exactly 5 times, I would do this:
for(int x = 0; x < 5; x++)
std::cout << "Hello, world!" << std::endl;
A [I]while()[/I]
loop is often used when you don't know how many times a loop should run, or are dependant on a changing condition to determined when you should exit the loop. For example:
#include <iostream>
int main() {
std::string input("");
while(input != "q") {
std::cout << "\nEnter a message (\'q\' to quit):\n>>> ";
std::getline(std::cin, input);
}
}
A
do {
} while()
loop is used when you always want something to happen once, and then check a condition to see if it should happen again.
Hope what helped somewhat. :)