C++ Help needed

  • Thread starter entei123
  • Start date
entei123

entei123

Nintendo 3DS Legend
Towns Folk
So ,I'm still only starting with C++ so please keep it easy on me. I want to make a simple quiz. This is my program. :
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
string answer;
cout << "Here would be question." << endl << "Write yes or no. " << endl;
cin >> answer;
if (answer== "yes" )
{
cout << "The answer is correct." << endl;
}
else if (answer== "no" )
{
cout << "The answer is wrong." << endl;
}
else
{
cout << "Write either yes or no." << endl;
}

system("PAUSE");
return 0;
}
So the program works perfectly. By I want to make it a QUIZ, not a question. So basically ifthe aswer is correct I want it to say what it says , and then to open a new .exe file with next question, which is on my desktop in folder "quiz" . I don't know how to do it ,and help would be really... helpful? xD I looked online and really nothing helps.
 
Why not embedding the question into your main.cpp file ?
Otherwise, try specifying the location of your .exe with the system command.
Like this :
system("C:\UserName\Desktop\Quiz\YourExe.exe");
As system() is basically a way to execute CMD commands into C/C++ apps, you could execute it like that.
 
Why not embedding the question into your main.cpp file ?
Otherwise, try specifying the location of your .exe with the system command.
Like this :
system("C:\UserName\Desktop\Quiz\YourExe.exe");
As system() is basically a way to execute CMD commands into C/C++ apps, you could execute it like that.
What do you mean by "embedding" ?
I did that but it didn't work. I then tried with double \ because ,one \ is Windows Explorer only. Final (kinda) solution is :
system("C:\\Users\\Mladen\\Desktop\\quizz\\Quizz.exe");
But it doesn't do exactly what I wanted since it boots up the question in the same window, but I can take it. Thanks a lot. But if somebody else knows a way to boot in a separate window it would be really good for me :p
 
What do you mean by "embedding" ?
I did that but it didn't work. I then tried with double \ because ,one \ is Windows Explorer only. Final (kinda) solution is :
system("C:\\Users\\Mladen\\Desktop\\quizz\\Quizz.exe");
But it doesn't do exactly what I wanted since it boots up the question in the same window, but I can take it. Thanks a lot. But if somebody else knows a way to boot in a separate window it would be really good for me :p

Hmm... Generally, when using \ (and not \\), it works. By embedding, I mean, reproducing the question inro your "main" function.
 
Hmm... Generally, when using \ (and not \\), it works. By embedding, I mean, reproducing the question inro your "main" function.

He is a beginner, so I think you're going to have to use more basic terms.

I think the program is going to be written depending on what the question is.
 
All i have to say is you gotta give a specific address for it to find the folder on CMD try creating batch with notepad this might help execute the file more faster without having intering codes in cmd it's actually a shortcut but nothing change since you gotta make a command to be run on cmd by converting a txt format into a batch format and don't forget to do it like this C\Document and settings\user\folder\file you want to edit or move
 
Back
Top