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;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top