Sign in to follow this  
Shakedown

Why is nothing being printed on the screen?

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 this post


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

#include <iostream.h>

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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this