6

My code has everything ok! But I don't get any output on the console. This is my code:

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

int main()
{
    printf("Hello world!\n");
    return 0;
}
3
  • A simple question for you, Did you run it ? Commented Mar 5, 2015 at 13:27
  • 1
    Coming soon, where is semicolon located on my keyboard? Commented Mar 5, 2015 at 13:59
  • Running the program from the Windows GUI, the first time I saw a very brief console window outline on the screen, the second and subsequent times, I saw nothing (due to caching?). What happens when you run your program from a console? Commented Mar 5, 2015 at 14:02

5 Answers 5

1

Click on build->run or hit Ctrl+F10 and a new CMD Window should pop up, showing you your "Hello world!".

Sign up to request clarification or add additional context in comments.

Comments

1

I think Anti-virus might be causing a problem for you. Try excluding the folder that contains your file. There was another question posted with same problem and for that excluding the folder worked. Code::Blocks console app won't show output

Comments

1

I experienced this same problem on linux; installing xterm solved the problem for me.

See Settings > Environment > General Settings > Terminal to launch console programs

1 Comment

Changing to Terminal is probably preferable, but for installing xterm: stackoverflow.com/a/33893916/1599699
0

Please include getchar() in the function before return statement. This happens because the computer is executing your program and doesn't wait for you to see the output. Including getchar(), at the end mandates it to wait for an input & in the meanwhile you can observe your output

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

int main()
{
    printf("Hello world!\n");
    getchar();
    return 0;
}

Comments

0

You can use the following command to use linux terminal, and it is tested by me.

gnome-terminal --geometry=80x20+300+240 -x

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.