cout<<"Would you like to skip file work? (Yes / No)"<<endl<<endl;
cin>>lol;
do{
if(lol=="Yes")
{
cout<<"You skip file-work."<<endl<<endl;
goto skipfile;
}
elseif(lol=="No")
cout<<"You don't skip file-work."<<endl<<endl;
}while(!lol=="Yes"||!lol=="No");
cout<<"You need to use a capital at beginning, and spell it correctly."<<endl<<endl;
That fixed the no-match problem, but I got a
In function 'int main()
error: expected primary-expression before 'not_eq' token|
error: expected primary-expression before 'not_eq' token|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
cout<<"Would you like to skip file work? (Yes / No)"<<endl<<endl;
cin>>lol;
do{
if(lol=="Yes")
{
cout<<"You skip file-work."<<endl<<endl;
goto skipfile;
}
elseif(lol=="No")
cout<<"You don't skip file-work."<<endl<<endl;
}while (not_eq lol=="Yes"||not_eq lol=="No");
cout<<"You need to use a capital at beginning, and spell it correctly."<<endl<<endl;
void FileRead(void){
char filename[50];
char word[50];
ifstream myfiles(filename);
cout<<"Please type the name of the file you wish to read."<<endl<<endl;
cin.getline(filename, 50);
//if(myfiles)
// cout<<filename<<" exists, and can now be read."<<endl<<endl;
// if(!myfiles)
//cout<<filename<<" doesn't exist, and will not be read."<<endl<<endl;
//return;
myfiles.open(filename);
myfiles >>word;
while(myfiles.good()){
cout<<word<<" ";
myfiles>>word;
}
}
On line 5, you are constructing an ifstream object that is attempting to open the file specified by filename. Because filename was never set to anything, it contains some default garbage. When ifstream tries to open that file on line 5, it fails because the file name does not exist.
Instead, you want to get the file name from the command line before attempting to open the file. You can do this by moving ifstream myfiles(filename);
to line 8.
Also, on line 13, you are trying to open the file again; that will crash and should be removed.