Jump to content

Recommended Posts

  • Solution
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

Ken

Do not be sorry, be better.

Link to comment
https://metin2.dev/topic/16255-help-fopen/#findComment-90269
Share on other sites

  • 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());

GetFirstLineFromFile("conta.txt")

or

GetFirstLineFromFile(PubLogFile)

client crash error ??????

 

thanks ken 

Link to comment
https://metin2.dev/topic/16255-help-fopen/#findComment-90271
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

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.