im having trouble to input data which includes space bar Using C
Clion (C99)
Inputing name of recipient ,final destination and the status of the package
char name_location_status[90];
char recipient[30];
char final_destination[50];
char status[10];
printf("Please enter , 1> Recipient-, 2> Final Destination- and 3>Delivery status :\n");
scanf("%s", name_location_status);
const char upper[2] = "-";
char *token;
token = strtok(name_location_status, upper);
int i=0;
while( i!=3,token != NULL )
{
(i==0) ? strcpy(recipient, token) :
(i==1) ? strcpy(final_destination, token) :
strcpy(status, token) ;
i++;
token = strtok(NULL, upper);
}
The program works fine if inputing (Rat-House-Arrived) which output (Rat House Arrived) But it wont work if the inputs contain spacebar (L Rat-Kitchen House-Not arrived) which output (L ��)
So is there a way that using scanf To input data like this ?
Blockquote(L Rat-Kitchen House-Not arrived),which is in a line
If no , can u show me da way ?To input that kind of data In a line