문제

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