How to scanf commas, but with commas not assigned to a structure? C

前端 未结 3 1133

I want to scanf input like: \"John, Surname, 9999\" and commas should not be assigned to the scanned variable; spaces at the end and start of input deleted... Now t

3条回答
  •  一生所求
    2020-12-21 22:51

    You can specify to match everything except commas:

    int c = scanf("%[^,], %[^,], %i", &p->name, &p->surname, &p->index);
    

提交回复
热议问题