c++ - Read an ifstream word for word into char* -


just trying programming test fun. stipulates should read each word of file, 1 one.

it hints might want use ifstream, won't let me use std::string, looks have use char*

in c read line line & use strok() have multiple delimiters (white-space, quotes, brackets, etc).

what c++ way - words 1 one - without using std::string ?

first must make sure have memory allocated string (this part handled automatically std::string). use normal input operator >>, separate on whitespace.

don't forget free memory allocate (also handled automatically std::string).

lesson learned: use char pointers exercises these, otherwise use std::string.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -