I'm having a bit of trouble compiling and running my .c file in terminal. First, when compiling, I see:
HW3.c: In function ‘main’:
HW3.c:87:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int j = 0; j < 10; j++) {
^
HW3.c:87:5: note: use option -std=c99 or -std=gnu99 to compile your code
HW3.c:100:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int j = 0; j < 10; j++) {
^
All of my variables are declared and assigned at the beginning of the program, including j, so I'm not sure why I'm seeing an error about 'for' loop initial declarations.
Secondly, when attempting to run my program, I type:
./a.out HW3.c
and see error
./a.out: Command not found.
What could possibly be the issue here? Is it not running because of the error in compiling? I'm sure I have the command right, right..? Let me know if you need to see the whole program to help, it's not too long, I could copy it over. Thanks!
You need to add a more recent C standard revision to your compiler options. Try adding the flag
--std=c99
and it should work.As for your second problem,
a.out
is the executable produced by the compiler. If there are errors in the program, it won't produce an executable, so you have to fix the errors.You can also specify the name of the executable with the
-o
flag:This will produce an executable named
HW3
.