Author Topic: Program Build/Make Problem  (Read 3051 times)

simmonz

  • Guest
Program Build/Make Problem
« on: February 17, 2006, 07:00:24 pm »
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

  • Guest
Re: Program Build/Make Problem
« Reply #1 on: February 17, 2006, 07:04:48 pm »
This works. Why are you learning C instead of C++?

Code: C++
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char* argv[])
  4. {
  5.     printf("Hello World!\n");
  6.  
  7.     return 0;
  8. }
  9.  
« Last Edit: February 17, 2006, 07:06:20 pm by sethjackson »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Program Build/Make Problem
« Reply #2 on: February 17, 2006, 07:13:03 pm »
This works. [...]
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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

simmonz

  • Guest
Re: Program Build/Make Problem
« Reply #3 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.

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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Program Build/Make Problem
« Reply #4 on: February 17, 2006, 07:37:29 pm »
sethjackson.... i need to learn it as part of my course...we will be moving onto C++ at some point soon.
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).

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.
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)?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline keithrumph

  • Single posting newcomer
  • *
  • Posts: 1
Re: Program Build/Make Problem
« Reply #5 on: May 28, 2020, 02:15:04 pm »
Quote
from: customwritingz on February 17, 2006, 07:00:24 pm
 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.

Try to reset compiler to default settings. Go to settings>compiler>reset defaults. Maybe, it will help.