Jump to content
  • Advertisement
Sign in to follow this  

[ C++] file output error

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to implement a class Log for logging. Until now it has 1 function.
#ifndef MIN_LOG_H
#define MIN_LOG_H

#include <fstream>
#include <string>

namespace Min
	class Log
		Log(const std::string &outputFilename) : out(outputFilename.c_str()) {}
		// reports an error occured in a function
		void FunctionError(const std::string &function,
								const std::string &msg,
								const std::string &action = "unknown");

		std::ofstream out;

	static Log log("Min_Debug.txt");


// code file
#include "Min_Debug.h"

using namespace Min;
using namespace std;

void Log::FunctionError(const string &function, const string &msg, const string &action)
	out << "In function: " << function << endl
		<< "[" << msg << "]" << endl
		<< "Action taken: " << action << endl << endl;

int main()
log.FunctionError("main", "errr");

Nothing gets printed. What's wrong?

Share this post

Link to post
Share on other sites
Well, I would guess that the problem lies somewhere in the FunctionError() function. Of course, that's only a guess because you didn't post its definition.

Share this post

Link to post
Share on other sites
Original post by Dolf
It actually printed to a .txt file on my pc. It worked...

Thanks. I was doing something wrong in another function.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!