Jump to content
Maintenance ×
  • Create New...
  • 0

Help fopen



5 answers to this question

Recommended Posts

  • 1
  • Moon
std::string GetFirstLineFromFile(std::string stFileName)
	std::ifstream file(stFileName.c_str(), std::ios::in);
	if (!file.is_open())
		return "Can not open the file";

	std::string stLine = "";
	if (!getline(file, stLine))
		return "Can not get the first line!";

	return stLine;

It will get the first line of the file. You can use this anywhere you want. (Don't forget to include fstream and string libraries)

Best Regards


Do not be sorry, be better.

Link to comment
Share on other sites

  • 0
  • Premium

std::string GetExeFileName()
    char buffer[MAX_PATH];
    GetModuleFileName(NULL, buffer, MAX_PATH);
    return std::string(buffer);

std::string GetExePath()
    std::string f = GetExeFileName();
    return f.substr(0, f.find_last_of("\\/"));

    string baseLogDir = GetExePath();
    baseLogDir += "\\conta.txt";
    char* PubLogFile = _strdup(baseLogDir.c_str());




client crash error ??????


thanks ken 

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.

  • Activity

    1. 0

      erorrs after update granny to 2.9

    2. 0

      Navicat Premium 16.1.1 x64

    3. 5

      problem Dargon Soul Changre Attribute

    4. 5

      problem Dargon Soul Changre Attribute

    5. 41

      Global Chat

    6. 5

      problem Dargon Soul Changre Attribute

    7. 2

      Startup Loading Window Library

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.