GetPrivateProfileStringA() [Solved]

Posts 1–4 of 4 · Page 1 of 1
GetPrivateProfileStringA() [Solved]
I am trying to read info from my .ini file that i put in the same directory as my .exe but it's not reading the file. Here is my code:

Code:
#include <Windows.h>
#include <iostream>
using namespace std;


int main()
{
	
	char szbuffer[90];
	GetPrivateProfileStringA("Question", "Q", "no", szbuffer, 90, "God.ini");
	cout<<"The text I have found is: "<<szbuffer<<"\n";
	system("PAUSE");

}
God.ini
Code:
[Question]
Q = Thank God.
Any help is appreciated, thanks.
Code:
char szPath[MAX_PATH];
GetCurrentDirectoryA(MAX_PATH, szPath);

char buffer[90];
GetPrivateProfileStringA("Question", "Q", "No", buffer, 90, strcat(szPath, "\\God.ini"));
Try this?
Quote Originally Posted by master131 View Post
Code:
char szPath[MAX_PATH];
GetCurrentDirectoryA(MAX_PATH, szPath);

char buffer[90];
GetPrivateProfileStringA("Question", "Q", "No", buffer, 90, strcat(szPath, "\\God.ini"));
Try this?
Thanks master, i knew it was going to be an issue with the directory. Thanks. I really appreciate it.
Marked Solved.
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us