-1

Here in this problem , have to store n strings (with length no more of 80).

Gets function is not taking the first string (because I think the problem is new line after n). I also tried "fgets(niza,81,stdin)" but was the same.

int main() {
    int n;
    scanf("%d",&n);
    while(n--)
    {
        char niza[81];
        gets(niza);
        transofrmiraj(niza,x);
        printf("%s\n",niza);
    }
    return 0;
}
Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
Rinor Ajdini
  • 13
  • 1
  • 8

2 Answers2

1

Your input is probably:

1
String

When you do:

scanf("%d",&n);

it is only removing 1, leaving an empty newline (because you COULD have: 1 first-string-here).

Replacing this with:

scanf("%d\n",&n);

will cause scanf to consume that newline.

Halt State
  • 421
  • 2
  • 6
0

You could change:

scanf("%d",&n);

to:

scanf("%d%*c",&n);

So that it will read and discard the newline character after reading the integer number.

isrnick
  • 621
  • 5
  • 12