Frage

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?

War es hilfreich?

Lösung

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;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top