Feb 28, 2015 at 11:41am
in file1.txt writes PRINT "some text123", and I want him to console shows "some text123" but he printed PRINT "some text123"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
ifstream ScriptFile("file1.txt"); // IN this:
string ScriptCode;
while(ScriptFile >> ScriptCode){
cout << ScriptCode;
}
if(ScriptCode == "PAUSE"){
system("pause");
} //error
if(ScriptCode == "PRINT"){
std::cout << ScriptCode.substr(3, 5) << std::endl; // She prit full string
} // error
system("pause >nul");
return 0;
}
|
Last edited on Feb 28, 2015 at 11:53am
Feb 28, 2015 at 11:53am
in file1.txt writes PRINT "some text123", and I want him to console shows "some text123" but he printed PRINT "some text123"
Feb 28, 2015 at 12:07pm
Do you speak English?
Are you saying that in a file (file1.txt) there is some text
When you read the file and write to the console you get
But your desired output on the console is to leave out "PRINT" and get just
??
Last edited on Feb 28, 2015 at 12:08pm
Feb 28, 2015 at 12:19pm
YES MAN :)
My grammar is a little bad :S
Feb 28, 2015 at 12:26pm
read all the words from a file to an array. Then read the array from the second word.