Hi! how you all going? I'm hoping you will help me with this little problem
I was wondering how do I make my program stop reading the file and storing it into the array once it encounters a 'whitespace'. Right now it is reading the whole string.
--------------
--------------
The file that it is reading from is something like this....
Name 828283
Name2 4343487
Name3 45894
---------------
--------------
#include <iostream.h>
#include <string.h>
#include <fstream.h>
#define size 10
class List_class
{
private:
char names[size][20];
public:
List_class();
void to_screen ();
};
void main(void)
{
__List_class num_list;
__num_list.to_screen ();
}
List_class::List_class()
// reads the list in from a file
{
fstream infile ("Names.dat", ios::in);
for (int a = 0; a < size; a++) {
__infile >> names[a];
}
infile.close();
}
void List_class::to_screen ()
// displays the list to the screen
{
cout << "This is the list: " << endl << endl;
for (int a = 0; a < size; a++) {
___cout << names[a] << " ";
__}
}
Greatly appreciated