![]() |
|
How to run your program. - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: C, C++, & Obj-C (https://sinister.ly/Forum-C-C-Obj-C) +--- Thread: How to run your program. (/Thread-How-to-run-your-program) |
How to run your program. - MRIDGAF - 06-07-2014 Ok so currently I am reading C Programming : Absolute Beginner's Guide, and am trying to follow along by writing and running the code. Anyways, I downloaded Cod::Blocks IDE and went to File > New > Empty File, and then wrote a simple 'Hello world' program and proceeded to build and run it. According to the book, the program should have popped up in a terminal but nothing happened, can someone help me please? Thank you. P.S. I wrote the code properly, I quadrouple checked the thing, I used #include <stdio.h>, main(), printf(), return 0, and put all the semicolins. RE: How to run your program. - The Real Slim Shady - 06-07-2014 Hard to tell you whats wrong when all youve done is say it doesnt work and you promise the code is correct. Operating System, the Code, IDE version, and any errors or error logs that might be generated are all pretty important to debug problems. RE: How to run your program. - MRIDGAF - 06-07-2014 OS: Linux Mint 17 Code: #include <stdio> main() { printf("Hello world./n"); return 0; } Code::Blocks Version: 13.2 Code::Blocks Build Log: Checking for existance: /home/myname/Documents/Untitled1 Execting: xterm -T '/home/myname/Documents/Untitled1' -e /usr/bin/cb_console_runner "/home/myname/Documents/Untitled1" (in /home/myname/Documents) Process terminated with status 255 (0 minute(s), 3 second(s)) I do not believe the problem is that I did somthing wrong, but I didn't do somthing I needed in order to have the program pop up in a terminal when it runs. RE: How to run your program. - alok9shm - 06-07-2014 Maybe xterm is missing. Install xterm: Quote:% sudo apt-get install xterm And then try to compile your program. RE: How to run your program. - erpicci - 06-07-2014 Have you considered compiling and running your code directly from the terminal? In my opinion, it could be good for a beginner because this lets you "touch" the compiler. (06-07-2014, 02:20 AM)MRIDGAF Wrote: Just a few notes: while "main()" is enough, the compiler should warn you about missing return type (and parameter), hance you should prefere "int main(void)"; in the "printf" you used "/n", while you probably meant "\n", with backslash (escape sequence). RE: How to run your program. - ArkPhaze - 06-12-2014 (06-07-2014, 09:07 AM)erpicci Wrote: Have you considered compiling and running your code directly from the terminal? In my opinion, it could be good for a beginner because this lets you "touch" the compiler. It's best to be explicit, yes. If the compiler gives you a warning, that's more often than not an indication that you're doing something bad. And: Code: #include <stdio>Should be... Code: #include <stdio.h>If nobody else within this thread caught that from a hello world example in C, then none of the above members should be trying to help others in C programming related threads IMHO... @OP: next time if you're having issues with code, don't assume that you've written things properly as you clearly didn't... Your original post states that you included <stdio.h>, yet I see <stdio> which is wrong... If you get a compiler error, you DIDN'T write everything properly. Here is the proper code: Code: #include <stdio.h>
int main()
{
printf( "Hello world.\n" );
return 0;
} |