?? fileoperation.txt
字號:
1.打開文件
char* pFileName = "test.dat";
CStdioFile f1;
if( !f1.Open( pFileName,CFile::modeRead | CFile::typeText ) ) {
#ifdef _DEBUG
afxDump << "Unable to open file" << "\n";
#endif
exit( 1 );
}
2.讀文件
char buf[100];
f1.ReadString( buf, 99 );
buf中數據為"1 2 4 6 7"
3.分離元素
int i;
int count=0;
char ch;
char xbuf[100];
memset(xbuf,0,100);
int j = 0;
for( i = 0; i < strlen(buf); i ++ ) {
ch = buf[j++];
xbuf[i]=ch;
if( ch == ' ' ) {
count++;
//此時xbuf中存了一個元素,將其賦給其它變量
memset(xbuf,0,100);
j=0;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -