int shutdown()
{
int time;
int hmm;
string name2file;
string name;
string nametofile;
string name2;
ofstream file;
ofstream file2;
cout << "\nHow long do you want to wait till shutdown?(in seconds)\n";
cin >> time;
cout << "What would you like to name the batch file?\n";
getline(cin,name);
name2file = name + ".bat";
const char *x = name2file.c_str();
file.open (x);
cout << "\n";
cout << "What text do you want when closeing?\n";
cin >> name2;
nametofile = name2;
const char *y = nametofile.c_str();
file << "start shutdown.exe -s -t " << time << " -c " << y;
file.close();
cout << "Shutdown batch was made.\nwould you like to make a batch to abort shutdown?\nAbore batch is the same as restarts abort.\nEnter 1 if yes.\n";
cin >> hmm;
if(hmm == 1)
{
file2.open ("Abort .bat");
file2 << "shutdown -a";
file2.close();
}
system("PAUSE");
return 0;
}
This is just a function from my program but when i run it and after i enter the time it just skips asking the name and just ask for the message. Anyone no how to fix it?