User forums > Help
Program Build/Make Problem
(1/1)
simmonz:
I'm new to compiler and also relatively new to the C language so please forgive me if this may sound dumb. I wrote a simple program to display "Hello world" as described in my tutorial book for C. I was able to compile the code but was unable to Build or Make the program. This is the same program which I used on my course at college in todays programminng lesson. The code is below.
#include <stdio.h>
main()
{
printf("hello, world\n");
}
This compiles the program but does not display the "Hello world" text as it did in my lesson. My college is using the Visual Studio product but as I wish to learn from home using manuals etc I'm not even sure if the code is right, although I believe it is.
Any help would be appreciated
Thank you
sethjackson:
This works. Why are you learning C instead of C++?
--- Code: (cpp) ---#include <stdio.h>
int main(int argc, char* argv[])
{
printf("Hello World!\n");
return 0;
}
--- End code ---
thomas:
--- Quote from: sethjackson on February 17, 2006, 07:04:48 pm ---This works. [...]
--- End quote ---
The original code works too (in C).
There may be several reasons why you see no output. Did you press the run button (a blue triangle in the toolbar) to run it, or did you launch it from Explorer?
In the latter case, you may see a black square flash up for the fraction of a second. That is your program's console ( = output area) opening and closing again. It is only going too fast, so you don't see the "hello world". Run using the toolbar button, or start a DOS window first.
simmonz:
sethjackson.... i need to learn it as part of my course...we will be moving onto C++ at some point soon.
thomas... there build/make and run buttons are both "greyed" out at the top. I cannot click them from the toolbar or from the menu and the shortcut commands do not work either.
thomas:
--- Quote from: simmonz on February 17, 2006, 07:26:42 pm ---sethjackson.... i need to learn it as part of my course...we will be moving onto C++ at some point soon.
--- End quote ---
Once you do that, remember that main must not return void in C++. When you compile as C++, you must rewrite the function in the way Seth pointed out earlier (it is still perfectly correct in C).
--- Quote from: simmonz on February 17, 2006, 07:26:42 pm ---thomas... there build/make and run buttons are both "greyed" out at the top. I cannot click them from the toolbar or from the menu and the shortcut commands do not work either.
--- End quote ---
I take it you use RC2 then... that version does not allow you to do most things without having a project.
If you make a project (choose "New Project" and use the "console app" template), you should be able to use those buttons.
If they are still dead when having a project, it may be due to a bug in the RC2 version related to a corrupted toolbar layout (delete a file named .codeblocks.layout which is in your home directory).
Did you try running your application from a cmd prompt (DOS window)?
Navigation
[0] Message Index
Go to full version