Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: steve1_rm on September 11, 2008, 06:45:58 pm

Title: no console displayed when running C program
Post by: steve1_rm on September 11, 2008, 06:45:58 pm
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


Title: Re: no console displayed when running C program
Post by: DrewBoo on September 11, 2008, 06:56:57 pm
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?
Title: Re: no console displayed when running C program
Post by: steve1_rm on September 12, 2008, 04:43:20 am
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,
Title: Re: no console displayed when running C program
Post by: MortenMacFly on September 12, 2008, 08:49:45 am
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.
Title: Re: no console displayed when running C program
Post by: steve1_rm on September 12, 2008, 09:42:56 am
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;
}
Title: Re: no console displayed when running C program
Post by: steve1_rm on September 14, 2008, 07:46:37 am
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,

Title: Re: no console displayed when running C program
Post by: Barking_Mad on September 18, 2008, 01:16:13 am
Try running it from a test bat/cmd file:

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

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

Just to eliminate some possibilities.