On the coding side, since this is C++, don’t store lists of strings in a two-dimensional array of char. Try std::vector<std::string>
instead. And don’t read your file one character at a time; read larger blocks of characters.
If you can guarantee that there are never spaces embedded within first names, you can write something like cin >> s;
, where s
is of type std::string
, to read a whole name in one operation.
If you may have blanks within a name, try reading an entire line of the file into an std::string
and extract the data you need from there. If that’s too complicated, maybe you need to reconsider your input file’s format. (Maybe include a sample of an input file next time so we can see what you thought you were trying to read.)
solved C++ double char array deliminator [closed]