C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// SIMPLE FGETS NEWLINE TEST
// This program simply asks for n 10-character (at most) strings and combines the first letter of each string and outputs it.
// Here, fgets seems to only ask for n-1 strings.
// The first fgets seems to take the newline from the previous scanf input.
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
char result[n + 1], temp[10];
result[n - 1] = '\0';
for (int i = 0; i < n; i++) {
fgets(temp, 10, stdin);
result[i] = temp[0];
}
printf("%s\n", result);
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run