Actually in C++ it's just istream.getline(array_name, block_size); , or with strings getline(istream, string_name); .
Also don't you need strncat() to append data? You would also probably need a 2D array to hold multiple strings.
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116
data[ i ] += theWord; Remember, strings are not variables in C, but a sequence of chars terminated by the '\0'. Assignment can not be achieved directly, you have to use a piece of code that would assign one char at a time respectively.
strcpy(), strncpy(), strcat() and strncat() are standard functions that will handle some of these tasks. Make sure you include string.h header file. fgets( theWord, sizeof( theWord ), stdin ); Do not assume that fgets() will always be able to read successfully.
Only if..
if (fgets(theWord, sizeof theWord, stdin) != NULL)
/* then copy or concatenate the read string */
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
Please read the rules, me_ansh, and you'll find what you've done wrong.
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116