65,211
社区成员
发帖
与我相关
我的任务
分享
vector<string> *wlines_of_text = new vector<string>;
ifstream winfile( "a.txt", ios::in );
if ( !winfile )
cout << "Error! cannot open file" <<endl;
string wlineContent;
//用于读取文件的每一行内容
while( getline( winfile, wlineContent, '\n' ) )
wlines_of_text->push_back( wlineContent );
/* fseek example */
#include <stdio.h>
int main ()
{
FILE * pFile;
pFile = fopen ( "example.txt" , "w" );
fputs ( "This is an apple." , pFile );
fseek ( pFile , 9 , SEEK_SET );
fputs ( " sam" , pFile );
fclose ( pFile );
return 0;
}
After this code is successfully executed, the file example.txt contains:
This is a sample.