Author Topic: no console displayed when running C program  (Read 9753 times)

Offline steve1_rm

  • Single posting newcomer
  • *
  • Posts: 8
no console displayed when running C program
« 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



Offline DrewBoo

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: no console displayed when running C program
« Reply #1 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?

Offline steve1_rm

  • Single posting newcomer
  • *
  • Posts: 8
Re: no console displayed when running C program
« Reply #2 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,

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: no console displayed when running C program
« Reply #3 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline steve1_rm

  • Single posting newcomer
  • *
  • Posts: 8
Re: no console displayed when running C program
« Reply #4 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;
}

Offline steve1_rm

  • Single posting newcomer
  • *
  • Posts: 8
Re: no console displayed when running C program
« Reply #5 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,


Offline Barking_Mad

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: no console displayed when running C program
« Reply #6 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.
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