Why is nothing being printed on the screen?

This topic is 3858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Ok so I'm working through this book "GAME PROGRAMMING ALL IN ONE, Third Edition," and I keep running into all these stupid compiler errors ( missing msvcr80.dll bullshit ), and once I finally get that taken care of...my printf's aren't working. Here's my code:
#include <stdlib.h>
#include <allegro.h>

int main(void){
allegro_init();
printf("Allegro version = %s\n", allegro_id);
printf("\nPress any key...\n");
system("PAUSE");
allegro_exit();
return 0;
}
END_OF_MAIN()


I also tried adding #include <stdio.h> but that didn't help. I'm using VC++ 2005 Express Edition, and I already went to properties and changed my file to compile as C, and saved the source as "main.c" but it don't want to work. And the only thing that is display when I run this is the system("PAUSE") ( "Press any key to continue..." ). What's the deal? [Edited by - Shakedown on May 23, 2007 10:33:36 PM]

Share on other sites
Stdio.h isn't enough; you must include iostream.h to use printf or cout.

#include <iostream.h>

Simple.

Share on other sites
Quote:
 Original post by dada222Stdio.h isn't enough; you must include iostream.h to use printf or cout. #include Simple.

This is wrong on multiple levels.

printf is in stdio.h not iostream.h (in C++ it would be cstudio, but we're using C here so stdio.h is fine)

iostream.h doesn't exist - it's prestandard. The header is "iostream" (Furthermore neither of these headers exists in C which the OP is using)

furthermore if the program runs then there isn't a compile or linking problem, so changing headers almost certainly won't fix anything.

Glancing at allegro briefly suggests that by default it uses some macro weirdness to change main into WinMain. This means that the printf isn't actually going anywhere. You might try adding:

#define ALLEGRO_USE_CONSOLE

Which should force a console entry point and might fix the problem you're seeing

Share on other sites

This topic is 3858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628702
• Total Posts
2984297

• 23
• 10
• 9
• 13
• 13