If you need a string - use char *
, char [SOME_CONST]
or std::string
(the latter is preferable, since this is a specialized class of strings, so there is less chance of running into memory problems)
If you need an array of strings (really needed) - either a pointer to a pointer, or std::vector<std::string>
(desirable). For the passage through the vector will have to use iterators. It is not as scary as it sounds.
Entering lines from the keyboard can be done in many ways. Starting from character, ending line by line. scanf("%s", pointer_to_char_arr)
normal with scanf("%s", pointer_to_char_arr)
, fgets()
, std::getline
or cin::getline
. In short, the ways mass. It is necessary to pay special attention for not going beyond the boundaries of buffers and to work carefully with pointers (if you use them).