Hello, I'm trying to write a program that is supposed to be a tool of sorts for another program I'm working on, and I am storing what I want to be written to the file in strings until the program gets to the writing portion. The IDE I'm using is Dev-C++ 4.9.2-ish, with g++.exe for my C++ compiler. There are several errors that are being shown between lines 49 and 58. The error on 49 is "no match for 'operator<<' in 'fichier << i_path' ", on 50" invalid operands of types `std:fstream ()(std::string)' and `int' to binary `operator<<' ", 51 "no match for 'operator<<' in 'fichier << keyword' ", 52 "no match for 'operator<<' in 'fichier << question' ", 55 "no match for 'operator<<' in 'fichier << choice[counter]' ", and with 58 " invalid operands of types `std:
fstream ()(std::string)' and `int' to binary `operator<<' ". If someone can explain what these errors mean and/or how I can resolve them, please reply. Below is the program's code.
Warning! This is code! (Bad MythBusters spoof, all well...):
Code:#include <iostream> #include <sstream> #include <string> #include <fstream> using namespace std; int main(){ cout<<"Welcome to the CHEM BOWL 2008 Question Maker program. Using this\nprogram, you will be able to make question files"; cout<<"for use with the CHEM BOWL 2008 Review Program.\n"; cout<<"To start, please enter the local path of an image you want to associate with this question.\n"; cout<<"If you don't want to supply an image, type none.\n"; cout<<"Example: Images\acids.bmp\n"; string i_path; getline (cin, i_path, '\n'); cout<<"Now, please enter the difficulty of the quetion, on an integer scale of between 1 and 10 inclusive.\n"; int difficulty; cin>>difficulty; cout<<"Here, you can supply a keyword to find an appropriate review section with.\n"; string keyword; getline (cin, keyword, '\n'); cout<<"On this line, please type your question.\n"; string question; getline (cin, question, '\n'); cout<<"Here, type the first choice.\n"; string choice[4]; getline (cin, choice[0], '\n'); cout<<"Here, type the second choice.\n"; getline (cin, choice[1], '\n'); cout<<"The third choice.\n"; getline (cin, choice[2], '\n'); cout<<"The fourth choice.\n"; getline (cin, choice[3], '\n'); cout<<"And finally, the fifth choice.\n"; getline (cin, choice[4], '\n'); cout<<"Here, type the number of the correct choice.\n"; int correct_choice; cin>>correct_choice; cout<<"Give this file a number that is not already used by another question here.\n"; string id; getline(cin, id, '\n'); //This section writes the file. string file; string txt; txt=".txt"; file=id+txt; ofstream fichier (string file); fichier<<i_path; fichier<<difficulty; fichier<<keyword; fichier<<question; for (int counter=0;counter<=5;counter++){ fichier<<choice[counter]; } fichier<<correct_choice; cout<<"The file should be created, please check."; cin.get(); }



LinkBack URL
About LinkBacks
fstream ()(std::string)' and `int' to binary `operator<<' ", 51 "no match for 'operator<<' in 'fichier << keyword' ", 52 "no match for 'operator<<' in 'fichier << question' ", 55 "no match for 'operator<<' in 'fichier << choice[counter]' ", and with 58 " invalid operands of types `std:



but yea what daved just said.