L
las
code :
char *programs[5];
ifstream file("...");
for(int index=0;index<5;index++)
{
programs[index]=new char[21];
file.getline(programs[index], 21, ' ');
cout << *program[index] << endl;
}
This runs fine but it only prints the first char. I thought getline was
suppse to automatically add a null terminating char, hence the whole word
should be printed.
also tryed using get
for(int index=0; index<5; index++)
{
programs[index]=new char[21];
data.get(programs[lp], 21 ,' ');
data.ignore(1,' '); //remove space
// how do I add null terminating char to programs[lp] ?
}
Thanks for any help.
char *programs[5];
ifstream file("...");
for(int index=0;index<5;index++)
{
programs[index]=new char[21];
file.getline(programs[index], 21, ' ');
cout << *program[index] << endl;
}
This runs fine but it only prints the first char. I thought getline was
suppse to automatically add a null terminating char, hence the whole word
should be printed.
also tryed using get
for(int index=0; index<5; index++)
{
programs[index]=new char[21];
data.get(programs[lp], 21 ,' ');
data.ignore(1,' '); //remove space
// how do I add null terminating char to programs[lp] ?
}
Thanks for any help.