I'm trying to solve but I don't know where a mistake.
int main() {
for (int i = 0; i < 3; i++) {
pid_t pid = fork();
}
return 0;
}
You're declaring your i variable inside the for loop. This is common in C++, but was added (surprisingly recently) in the C99 specification.
Move the declaration of your i variable outside of the for loop:
int main() {
int i;
for (i = 0; i < 3; i++) {
pid_t pid = fork();
}
return 0;
}
Alternatively, you can tell GCC to compile your code in C99 mode:
gcc -std=c99
Or if you want to retain GCC-specific features, use:
gcc -std=gnu99