   Reading in from a file and setting variables
  I was wondering if anyone could point me in the right direction for reading in information from a file, and then using what is read in to set a few variables. here is the situation:in the file chardata.txt is:vladmerewarrior10911now i want to read this file and put the data from each line into its own variable.what is the proper method for reading in the whole line that contains "vladmere" and storing it in a string variable called name.i know i need to start with:ifstream myfile;myfile.open("chardata.txt");if(myfile.is_open()){ /*not sure how to read in the lines*/}any help would be appreciated.   
  What you're looking for is the std::getline function.string name;getline(myfile, name);It can also take an optional 3rd parameter to specify a character to stop reading at. See here for more info.   ;  ok so i am using the getline() function to retrieve the data from my file chardata.txtmy chardata.txt file contains:vladmerewarrior10911and here is the code I have to retrieve that data, it works fine if i just have the first two getlines() however when i added the rest to get the int values dev-c++ gives me an error saying "no matching function for call to `getline(std::ifstream&, int&)'"string cname;string cclass;int char_attack;int char_defense;int char_power;int char_knowledge;ifstream chardata;chardata.open("chardata.txt");if(chardata.is_open()){ getline(chardata, cname); getline(chardata, cclass); getline(chardata, char_attack); getline(chardata, char_defense); getline(chardata, char_power); getline(chardata, char_knowledge);}im not understanding why it is having an issue with the intsEDIT: does getline only work for reading in strings? If so how would I accomplish extracting the numbers as ints?   ;  Simple. getline doesn't understand ints it only understands strings. But that's fine! It's better to read in the input as a string and then try to convert it. Way less messy, especially since cin, although convenient, is pretty crappy at validating input. If you had boost installed (i'm guessing not) then you could just use lexical_cast which can convert between types very easily and intuitively. However, you probably don't have boost. But no worries! The standard library class stringstream allows us to convert from std::string to all of the standard types. I don't have a lot of time to write or find a great example, but if you go here you will get some sample code and a more thorough explanation that should get you started.In order of preference I think you should do this:1)use the boost library for lexical_cast2)implement your own version of lexical_cast by using templates to transform from one type to another. If you already know how to use templates then doing this shouldn't be terribly difficult.3)wrap the conversion into functions like: int stringToInt(const std::string &input); or double stringToDouble(const std::string &input);4)convert from string to your desired data type directly inside your codeHope this helps   ;  getline() reads a line into a string. It doesn't understand the concept of integers.There are two solutions. You can simply start using operator >> once you have read the text. This assumes that there is only one game character in a particular file, because otherwise you will be mixing getline() and operator>>(), which can often lead to confusion. This is because operator>>() will stop at a newline, but also leave it in the buffer. A subsequent call to getline() will read and return an empty string. In contrast, getline() consumes the newline.You can alternatively read the lines as strings and reparse them as integers. We can write a function to handle this for us:#include <sstream>std::istream &getline_integer(std::istream &in, int &value){std::string string;if(std::getline(in, string)){std::stringstream stream(string);// Check if read successful// Also check there is no more information in the streamif(!(stream >> value && stream.eof())){in.setstate(ios_base::failbit);}}return in;}// meanwhile, back in the city...string cname;string cclass;int char_attack;int char_defense;int char_power;int char_knowledge;// no need to manually call "open()", just use the constructor.ifstream chardata("chardata.txt");if(chardata.is_open()){ getline(chardata, cname); getline(chardata, cclass); getline_integer(chardata, char_attack); getline_integer(chardata, char_defense); getline_integer(chardata, char_power); getline_integer(chardata, char_knowledge);}A more robust version would use boost::lexical_cast<> instead of stringstream.   