[close] ifstream read file, thanks!
---------------------------------------------
My config.ini content:
c:\program\edit plus\editplus.exe
---------------------------------------------
Abnormal Output: c:\program\editplus\editplus.exe [the blank missed between edit AND plus?]
Code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
void main() //the program starts here
{
ifstream OpenFile("config.ini");
char ch[80];
int i;
while(!OpenFile.eof())
{
OpenFile >> ch;
cout << ch;
}
cout << endl;
OpenFile.close();
cin >> i;
}
Abnormal output: c:\program\edit plus\editplus.exee (double e)
Why ?
Code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
void main() //the program starts here
{
ifstream OpenFile("config.ini");
char ch;
int i;
while(!OpenFile.eof())
{
OpenFile.get(ch);
cout << ch;
}
cout << endl;
OpenFile.close();
cin >> i;
}