How to read string separated by / with scanf

后端 未结 2 903
青春惊慌失措
青春惊慌失措 2020-12-20 01:06

I`ve been trying to this for quite a while now and after some research I had no success, so my last resort was asking a question. My input looks like this:

1         


        
2条回答
  •  一整个雨季
    2020-12-20 01:48

    You already got quite close: you missed to consume the delimiter in your second approach:

    scanf("%[^/]/%[^/]/%[^/]/%[^/]", str1, str2, str3, str4);
    

    should do the job.

提交回复
热议问题