So stuff like async file IO doesn’t go here, This is about what iostreams actually tries to do butįails at in some way. This is not about a list of things you wish itĬould do. We know what the real problems are, we can be certain that any new On exactly that: identifying the problems with the library. Order to eventually solve that problem, we must first identifyĮxactly what the problems are. Kind of thing is indicative of a real problem in iostreams. This is not due to differing ideas onĬ++ or C-in-classes-style development, but the simple practical We have real, reasonable, legitimateĬ++ professional, who like C++ and use modern C++ idioms, telling if you just change string on line 6 of the first image to ifstream& it should work.Library in C++ has a problem. Instead, you should rewrite countLines so that it accepts a std::ifstream& (reference since you can't copy an ifstream). You have countLines(string) defined instead. The type of dataFile is a std::ifstream as seen on line 12, so this is countLines(std::ifstream) but that's not defined. Then on line 24 you have countLines(dataFile). And since that's in main() you shouldn't exit(1) you should just return 1. And you should probably not call if(dataFile.fail()) but instead just use if(!dataFile). Then on line 16 you re-open the file? Just delete line 16, it's not necessary. You fail there std::getline is defined but not with two string parameters.įor image 2, on line 12 you're opening the file SampleInput.txt and associating it with dataFile. Remember, in C++ you need to have matching function names, parameter counts, and parameter types. So that's std::getline(string, string) which doesn't exist so you get a "no matching function call" error. Looking at where those variables are declared, line is a std::string as shown on line 10 and fileName is also a std::string as seen on line 6 in the function parameters. Please disregard my method of presenting my code to you as I do not know a quicker way.įor picture 1, you have while(std::getline(fileName, line)). I thought I was a very self-sufficient student before this class. Yes, I am attending uni for this, but honestly, I must admit that I am not that smart and can use all the help I can get. I have been sitting on this issue for a few hours now and google is not my friend. I would really appreciate it if somebody could inform me of my errors or explain to me what I am missing and why. All I'm trying to do is use the getline function properly, butĪ.) I don't think I know what it actually does? I would really appreciate if somebody explained to me what the function is actually doing.ī.) I'm not sure I'm using it correctly, as I always get an error saying there is no matching function for call to 'getline('. I don't think I am understanding File I/O properly, and everywhere I look for resources just confuse me. Hello! Back again with a complete noob question. if your post does not appear in the new queue, just send a message to the moderators.make your questions relevant to other readers.give your post a meaningful title, i.e., NOT "I have a C++ problem" but, e.g., "Problem with nested for loops".thoroughly research for an answer first.Tips for improving your chances of getting helpful answers: Read these guidelines for how to ask smart questions.įor learning books, check The Definitive C++ Book Guide and Listįlair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page. Hasty-sounding questions get hasty answers, or none at all. New to C++? Learn at READ BEFORE POSTINGīefore you post, please read our sticky on proper code formatting. For general discussion and news about c++ see r/cpp. This is a subreddit for c++ questions with answers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |