This is my first program to take advantage of functions. For this program I am required to open up a text document called "station.tx t" which has numbers and names in various rows scattered about it. the user is allowed to input a name of a city and the program should look for the city throughout the entire file. Now since the text file has a header, I know that I must get rid of this header file to continue looking through the file. So here is my function thus far:
Now when I test, the output for cityname i get is: "LAMAR
I dont want the quotations there, is there any way to get rid of them?
Code:
// ******************************************************************* // * // This function is for cityreport. * // * // ******************************************************************* void cityreport() { char cityname[MAX], line[MAX]; int number; fstream indata; cout << "Please enter a U.S. city: "; cin.ignore (); cin.getline (cityname, MAX); cout << endl; cout << "You entered " << cityname << endl; indata.open("station.txt"); indata.getline(line, MAX, '\n'); indata >> number; cout << number << endl; for (int i = 0; i < 5; i++) { indata.getline(line, MAX, '\t'); } indata.ignore(); indata.getline(cityname, MAX, ','); indata.ignore(MAX, '\n'); cout << cityname << endl; return; }
I dont want the quotations there, is there any way to get rid of them?
Comment