User forums > Using Code::Blocks

no console displayed when running C program

(1/2) > >>

steve1_rm:
Hello,

This is my first time using codeblocks.

I am using release 8.02 and running on windows xp pro.

However, I have created a simple hello world console project application. It builds without errors but doesn't show the console window.

In my debug folder I do have the executable chapter1.exe. If I double click it it will run.

main.c
Linking console executable: bin\Debug\Chapter1.exe
LINK : bin\Debug\Chapter1.exe not found or not built by the last incremental link; performing full link
Output size is 16.50 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
 
I am using the visual 2005/2008 compiler.

Under 'project properties' - 'Build Targets' - I have checked 'Pause when execution ends'

However, this didn't solve the problem.

Many thanks for any suggestions,

Steve


DrewBoo:
Steve, check something for me...

From the top menu, go to Project->Properties...

Under the "Build targets" tab, you should see Type: Console Application

Is that what you see?

steve1_rm:
Hello,

Thanks for the reply.

Yes, I can confirm that console application has been selected.

The new project I created was a console project.

Thanks,

MortenMacFly:

--- Quote from: steve1_rm on September 11, 2008, 06:45:58 pm ---It builds without errors but doesn't show the console window.

--- End quote ---
Probably it does show the console window but very quickly? Remember that if your console application terminates and you don't use something like a "pause" or "getch" command or similar it will be closed automatically.

If you are using the debug target  C::B will use the console runner for you to run the application. In that case you would see the output.

steve1_rm:
Thanks for the reply.

I have added a getchar(), that should pause the execution until a user presses a key. However, this doesn't display the console window.

I am also using the debug target.


--- Code: ---#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Hello world!\n");

    getchar();

    return 0;
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version