64,654
社区成员
发帖
与我相关
我的任务
分享
#include <fstream>
#include <iostream>
using std::ifstream;
using std::cout;
using std::endl;
int main()
{
int i=1;
ifstream inputFile("d:\\urls.txt");
while(!inputFile.eof())
{
cout << inputFile.get()<<"\t"<<i++ << endl;
}
getchar();
}
#include <fstream>
#include <iostream>
using std::ifstream;
using std::cout;
using std::endl;
int main()
{
int i=1;
char a[100];
ifstream inputFile("1.txt");
while (! inputFile.eof())
{
inputFile.getline(a,100);
cout <<a<<i++ << endl;
}
}
----------------------------
output:
hello1
ddf2
fdsf3
fdsafsa4
Press any key to continue
#include <fstream>
#include <iostream>
using std::ifstream;
using std::cout;
using std::endl;
int main()
{
int i=1;
char a[100];
ifstream inputFile("1.txt");
while (! inputFile.eof())
{
inputFile.getline(a,100);
cout <<a<<i++ << endl;
}
}
----------------------------
output:
hello1
ddf2
fdsf3
fdsafsa4
Press any key to continue