G
Glen
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
/*char test[]="I Glen 21\0";*/
char* choice;
char* number;
char* title;
char test[100];
cin>>test;
choice=strtok(test," ");
title=strtok(NULL," ");
number=strtok(NULL," ");
cout<<choice<<"\n";
cout<<title<<"\n";
cout<<number<<"\n";
}
Why does the program not give the correct output when I use cin I only get
I\n and that all but when I use the hard coded one I get I\nGlen\n21\n
Thank-you
#include <string>
using namespace std;
int main(void)
{
/*char test[]="I Glen 21\0";*/
char* choice;
char* number;
char* title;
char test[100];
cin>>test;
choice=strtok(test," ");
title=strtok(NULL," ");
number=strtok(NULL," ");
cout<<choice<<"\n";
cout<<title<<"\n";
cout<<number<<"\n";
}
Why does the program not give the correct output when I use cin I only get
I\n and that all but when I use the hard coded one I get I\nGlen\n21\n
Thank-you