Combine SDL & Console Code ( 2 different main() ) ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef KD_CHARACTER_H
#define KD_CHARACTER_H

#include <string>
#include <fstream>
#include <iostream>

class KD_CHARACTER
{
public:
	KD_CHARACTER( const char *data_file );

private:
	std::string file_name;
	std::string char_name;
};

KD_CHARACTER::KD_CHARACTER( const char *data_file )
{
	std::ifstream filestr;

	filestr.open(data_file);

	if(filestr.is_open())
	{
		char next;
		while (!filestr.eof())
		{
			filestr >> next;
			std::cout << next;
		}

		filestr.close();
	}
}

#endif 


This class use console output

1
2
3
4
5
6
7
8
9
10
11
12
#include <SDL.h>
#include <SDL_ttf.h>
#include "KD_Character.h"

int main(int argc,char *argv[])
{
	KD_CHARACTER default("Character/default.dat");

	

	return 0;
}


This main uses SDL


I have 2 questions :

How can I combine these things ?
How I can switch off SDL,because it doesn't allow me to do console stuff after I set up SDL library.
For some stupid reason SDL on Windows redirects stdout to file. A quick search gave me this:
1
2
freopen("CON", "w", stdout);
freopen("CON", "w", stderr);

Another way is to recompile SDL with the macro NO_STDIO_REDIRECT defined. Not sure if any of this works but you could try.
Topic archived. No new replies allowed.