Sign in to follow this  
ICUP

fprintf not working

Recommended Posts

#include "SDL/SDL.h"
#include <stdio.h>
#include <stdlib.h>

SDL_Surface *g_pMainSurface = NULL;
SDL_Event g_Event;

int main( int argc, char *argv[] )
{
	if ( SDL_Init( SDL_INIT_VIDEO ) == -1 )
	{
		fprintf( stderr, "Could not initialize SDL!\n" );
		exit( 1 );
	}
	else
	{
		fprintf( stdout, "SDL initialized properly!\n");
		atexit( SDL_Quit );
	}

	g_pMainSurface = SDL_SetVideoMode( 640, 480, 0, SDL_ANYFORMAT );

	if (!g_pMainSurface)
	{
		fprintf( stderr, "Could not create main surface!\n" );
		exit( 1 );
	}

	for ( ;; )
	{
		if ( SDL_WaitEvent( &g_Event ) == 0 )
		{
			fprintf( stderr, "Could not create main surface!\n");
			exit( 1 );
		}

		// check the type of event
		if ( g_Event.type == SDL_QUIT )
		{
			fprintf( stdout, "Quit event has occurred.\n");
			break;
		}
	}
	fprintf( stdout, "Terminating program normally.\n" );
	return( 0 );
}
There is no file that is being created. fprintf does print out to a file right?

Share this post


Link to post
Share on other sites
Fprintf() prints to a file handle. Stdout and stderr are handles to the standard output and standard error streams, which typically go to the console, so fprintf(stdout,...) is actualy the same as printf(...). On Windows, SDL overrides them to files for convenience. You need to use fopen() to open a handle to a file.

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