I am a relative newcomer to C++. I have some history in BASIC (I like goto loops!), but the C++ syntax is new to me.
The program I am trying to create is a simple game modifier that changes a value in the game's user.ini file so that a new action will be bound to a certain key.
What I want it to do is open and run through the user.ini file, copying every line exactly until it finds the line that begins with "X=" (with X being the letter the user picked.) where I want to make it "X=playvehiclehorn 1" then continue on copying the rest of the lines of the program and stop when it reaches the end. I don't want the program to overwrite the file it reads from, just to make a copy in the same directory as the program is run, so the user can manually add it.
I am using Bloodshed Dev C++. The compiler is throwing some errors at me I have never seen before. It is giving me errors on lines that don't have any code and past the end of the program. I have used all these commands before, maybe not in the same program, so I should be able to make it work. But no one can honestly say the error messages in Bloodshed help a novice very much. Thanks in advance!
here is my code:
lines with errors are marked with: *linenumber*Code:#include <iostream> #include <cstdlib> #include <string> #include <fstream> using namespace std; int main() { char peeker = 'z', def = 'y', newkey = 'H', custkey = 'z', gettest = 'z', peeker2 = 'z', done = 'n'; string filename, linein; ifstream infile; ofstream outfile; while (def != 'y' || def != 'n') { cout << "Is your program installed in the default directory?" << endl << "c:\UT2004 (y/n): "; cin >> def; } if (def == 'n') { cout << "Enter the location of your user.ini file" << endl << "Example: c:\ut2004\system\user.ini" << endl << ": "; cin.ignore(400, '\n'); getline(cin, filename); infile.open(filename.c_str() ); } *29* else infile.open("c:\ut2004\system\user.ini"); if (!infile) { system("pause"); return 1; } outfile.open("user.ini"); cout << "Do you want to use the 'H' key? (y/n): "; while (custkey != 'y' || custkey != 'n') cin >> custkey; if (custkey == 'n') { cout << "Enter your new key to bind to the horn. It must be a CAPITAL letter." << endl << "Ex: H : "; cin >> newkey; while (newkey < 'A' || newkey > 'Z') { cout << " Invalid key, enter another: "; cin >> newkey; } while (!infile.eof()) { peeker = infile.peek(); if (peeker == newkey && done == 'n') { infile.get(gettest); peeker2 = infile.peek(); if (peeker2 == '=') { outfile << newkey << "=" << "playvehiclehorn 1" << endl; done = 'y'; infile.ignore(100, '\n'); } else { infile.putback(gettest); getline(infile, linein); outfile << linein << endl; } } else *79* { getline(infile, linein); outfile << linein << endl; } } infile.close(); outfile.close(); system("pause"); return 0; *90* }
here are my error messages
Line | Error
--------------
102: non-hex digit 'T' in universal-character-name
*note, the program has only 90 lines
79: non-hex digit 't' in universal-character-name
79: [Warning] unknown escape sequence '\s'
79: non-hex digit 's' in universal-character-name
29: non-hex digit 't' in universal-character-name
29: [Warning] unknown escape sequence '\s'
29: non-hex digit 's' in universal-character-name
In function `int main()':
*no line number
91: syntax error at end of input



LinkBack URL
About LinkBacks
I like goto loops!), but the C++ syntax is new to me.
. Thanks in advance!


