News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

no console displayed when running C program

Started by steve1_rm, September 11, 2008, 06:45:58 PM

Previous topic - Next topic

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.
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

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.


#include <stdio.h>
#include <stdlib.h>

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

    getchar();

    return 0;
}

steve1_rm

Hello,

I installed the same version on my works computer and had the same problem.

So, maybe I am doing something with the setup of my application.

Anyone who has any other ideas?

Thanks,


Barking_Mad

Try running it from a test bat/cmd file:

save the following as a .bat or .cmd file, then run it:


@echo off
echo "Starting test application...."
call "/path_to_executable.exe"
echo "Test Application done!"
@pause


Just to eliminate some possibilities.
WooF! WooF! - Ubuntu 8.10 & CB 5432 & GCC 4.3.2
To see the world in a grain of sand and heaven in a wild flower
To hold infinity in the palm of your hand and eternity in an hour - W.B