trying to get script to repeat

I have this script


#include <iostream>
#include <string>

using namespace std;
string start;
int main()
{
while (start == "s") false;

cout << "press s to start " << endl;

getline (cin, start);

if (start == "s")
{
//function call here
}
else
{
//dont know what goes here
}
return 0;
}

All I want to do is if the user enters any key but s I want the script to start over by asking "press s to start" again and would like this to happen until the user enters s

thanks for any help
I don't understand why false; is where it is. Why is it there? Regardless, it's causing you problems. Remove it and enclose the whole while body (not the condition). For example:

1
2
3
4
while(/*Condition*/)
{
    // Body
}

With false; where it is, the compiler will assume false is the only statement the belongs to the while loop. Without braces, only 1 statement can be executed by a loop.

Wazzak
Last edited on
I have this script
Yea, no you don't. C++ is not a scripting language
Topic archived. No new replies allowed.