problem with token

hi guys im having a problem with token that delimits "," ..

i have a program that accept a user input for example "ma,mb,mc" it successfully put the string into token and it result into..

ma
mb
mc

now when i type "marniel 647,a02,3" it outputs

marniel
(null)
(null)

what happen with that it also delimits the " " characters...

by the way this is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <conio.h>
#include <string.h>
#include <stdio.h>

main(){
 clrscr();
 char *token, *token1, *token2;
 char *usTring;
 printf("Enter a String: ");
 scanf("%s",usTring);
 token = strtok(usTring,"\n,");
 token1 = strtok(NULL,",");
 token2 = strtok(NULL,",");
 while (token != NULL){
  printf ("Emp Name: %s\n"
	  "Emp ID: %s\n"
	  "Emp sal Level: %s",
	  token,token1,token2);
	   token = strtok(NULL,",");
 token1 = strtok(NULL,",");
 token2 = strtok(NULL,",");
 }
 getch();
 return 0;
}
Topic archived. No new replies allowed.