0

I want to read two lines of input and after I read the first line, the output is automatically 0.

This is my input:

enter image description here

int main() {
    char s1[256], s2[256];
    int x, n;
    scanf("%d", &n);
    scanf("%[a-z,A-Z]%*2c%[a-z,A-Z]%*2c%d", s1, s2, &x);
    printf("%s %s %d", s1, s2, x);
    return 0;
}

Any ideas?

ocrdu
  • 2,172
  • 6
  • 15
  • 22
  • If you want to read "lines" of input why are you using `scanf` and not [`fgets`](https://en.cppreference.com/w/c/io/fgets)? – WhozCraig Jan 17 '21 at 12:03
  • checkout https://stackoverflow.com/questions/13592875/reading-multiple-lines-of-input-with-scanf) – maruf Jan 17 '21 at 12:11

0 Answers0