Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array of Strings

Status
Not open for further replies.

amalthea

Programmer
Joined
May 30, 2002
Messages
7
Location
US
Hi,
I need to create an array of strings. The input will include spaces, and I need the program not to terminate if a space is entered by the user. Any tips?
 
What library will you be using?
MFC?
STL?
A combination?
If you open a stream using the IOS library in the STL you can call a getLine function that doesn't terminate until, obviously, you have reached the end of the line. Is this what you're looking for? MYenigmaSELF:-9
myenigmaself@myenigmaself.gaiden.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra
 
Yes, what is the syntax for the getline function?
 
istream& getline( char* pch, int nCount, char delim = '\n' );
pch
A pointer to a character array.
nCount
The maximum number of characters to store, including the terminating NULL.
delim
The delimiter character (defaults to newline).

an example:
#include <iostream.h>
.....
.......
char *array = new char[100];
.....
cin.getline( array, 100, '\n' ); // or simply cin.getline( array, 100 )
....
.....
delete array;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top