Pourquoi ce code imprime-t-il le caractère sans le premier caractère ?? Il dit ocalhost
au lieu de localhost
. Reconnaissant de l'aide.Premier caractère qui disparaît dans ifstream
#include <winsock2.h>
#include <mysql/mysql.h>
#include <iostream>
#include <windows.h>
#include <fstream>
using namespace std;
int main() {
int b = 0;
char * pch;
int stringLength = 0;
char textRead[50];
ifstream infile("config.ini", ios::in | ios::binary);
if(!infile) {
cout << "ERROR: config.ini not found!\n";
system("pause");
exit(0);
}
infile >> textRead;
stringLength = strlen(textRead);
pch=strchr(textRead,'"');
while(pch != NULL) {
infile.seekg(pch-textRead-1);
infile >> textRead;
pch = strchr(pch+1,'"');
}
cout << textRead;
infile.close();
Impossible de dire sans le contenu de 'config.ini'. –
Pourquoi écrivez-vous du code pour analyser les fichiers INI? Vous utilisez clairement Windows, alors appelez ['GetPrivateProfileString'] (http://msdn.microsoft.com/en-us/library/ms724353.aspx) pour obtenir les valeurs INI dont vous avez besoin. –