C program
I have copied this program into pico and compiled it using cgg. Then I get an error that states, "Badly placed ()'s." Everything I'm reading tells me it should be done like this, so, I need assistance from experts. What am I doing wrong?
#include <stdio.h> int main() { int this_is_a_number; printf( "Please enter a number: " ); scanf( "%d", &this_is_a_number ); printf( "You entered %d", this_is_a_number ); getchar(); } |
Please post code inside [code] tags. This helps improve readability by using a fixed-width font and preserving whitespace.
What command are you using to compile and link the program. There is no cgg. Perhaps you mean gcc? Please post the exact command you used, and the output of that command. As far as I can see, your program should build OK. You should get into the habit of putting the argc and argv parameters to main, and explicitly return an integer value (0 for success, 1-127 for other statuses). |
Thank you. I did mean gcc. I copied the program into pico, and then ran gcc ctest.c. That reported nothing. Then, I typed at the command prompt "./ctest.c". That's when it errored with "Badly placed ()'s." I copied the program from a tutorial on line.
|
Code:
alucard@thrawn:~$ cat c.c I see what you're doing. You don't execute ctest.c, you execute the program produced by gcc. In my example the "-o c" named it "c". In yours, you got the default name, which iirc is "a.out". Try ./a.out or passing "-o outputname" to gcc. |
Thank you very much. I tried ./a.out, and that did it. I'm really glad you are there to help.
|
All times are GMT -5. The time now is 11:46 AM. |