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

前端 未结 3 1137

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

    Now that I have the declaration of struct student_t (and a glass of wine!)

    It should be

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

    And then check if c is 3

提交回复
热议问题