I want to read characters until third period encounters that is reading three strings.
I am using the following code
But it is reading only one stringCode:scanf("%s%,s,%s",str1,str2,str3);
please tell me how to read three strings
I want to read characters until third period encounters that is reading three strings.
I am using the following code
But it is reading only one stringCode:scanf("%s%,s,%s",str1,str2,str3);
please tell me how to read three strings
> scanf("%s%,s,%s",str1,str2,str3);
See it yet?
Besides, %s will also read commas, so all you'll end up with is one string "abc,def,ghi" in str1
If you want to do (simple) comma separated values, then use this
scanf("%[^,],%[^,],%[^,]",str1,str2,str3);
See your manual page for more details on the %[ format.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Sorry while posting I did mistake
Its not
Actually i am usingCode:scanf("%s%,s,%s",str1,str2,str3);
Code:scanf("%s,%s,%s",str1,str2,str3);