Question

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?

Était-ce utile?

La solution

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;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top