You can use two different format specifiers :
#include <stdio.h>
int main(void)
{
char part1[100],part2[100];
scanf("%99s%99s",part1,part2);
printf("%s,%s\n",part1,part2);
return 0;
}
سؤال
I have an input text in a single line of the form "part1 part2". How can i get in 2 different variables part1 and part2 if they have been input in the same line?
المحلول
You can use two different format specifiers :
#include <stdio.h>
int main(void)
{
char part1[100],part2[100];
scanf("%99s%99s",part1,part2);
printf("%s,%s\n",part1,part2);
return 0;
}