Develop
2013.04.23 15:40
[c++] mfc 파일 한줄씩 읽기.. ㅋㅋ
Views 28515 Comment 0
텍스트 한줄 읽기
char buffer[125], *ps; CString strName, strNum; CString readfilename = pDlg.GetPathName(); m_readfile = readfilename; FILE *stream = fopen(m_readfile, "rt"); if (stream == NULL) return; while (fgets(buffer, 125, stream) != NULL) // 텍스트파일을 한줄씩 읽습니다. { ps = strchr(buffer, '\n'); // 제일 뒤쪽의 new line의 char을 찿아. if (ps != NULL) *ps = '\0';// new line의 char을 null문자로 바꿉니다. int cn = 0; ps = strtok(buffer, ","); while (ps) { if (cn == 0) strName.Format("%s", ps); else strNum.Format("%s", ps); ps = strtok(NULL, ","); cn++; } TRACE("%s\r\n",buffer); }
바이너리 파일 읽기
FILE *rfp,*wfp; int c; if((rfp = fopen(rpath,"rb"))==NULL) return; if((wfp = fopen(wpath,"ab"))==NULL) { fclose(rfp); return; } while(1) { c = fgetc(rfp); if(!feof(rfp)) { int a = ftell(wfp); fputc(c,wfp); } else reak; } fclose(rfp); fclose(wfp);
MFC 파일 한줄씩 읽기
CStdioFile file(fileName, CFile::modeRead | CFile::typeText); while(1) { if ( !file.ReadString(str) ) break; } file.Close(); return true;
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
1077 | System/OS | [linux] ipchains 사용예(패킷 필터링) | hooni | 2003.04.23 | 14171 |
1076 | System/OS | [linux] ipfwadm를 이용한 패킷필터링(구버전) | hooni | 2003.04.23 | 13015 |
1075 | System/OS | [windows] 98/ME 속도 빠르게 튜닝(부팅,메모리,레지스터) | hooni | 2003.04.23 | 50439 |
1074 | System/OS | [windows] 도스 사용 팁 | hooni | 2003.04.23 | 17806 |
1073 | System/OS | [windows] 여러가지 활용 팁 | hooni | 2003.04.23 | 19969 |
1072 | System/OS | [windows] 배치(bat)파일 제작 방법 | hooni | 2003.04.23 | 17002 |
1071 | System/OS | [linux] 패킷 스니퍼링 | hooni | 2003.04.23 | 16315 |
1070 | System/OS | [linux] 패킷의 소스 주소 바꾸기 | hooni | 2003.04.23 | 18784 |
1069 | System/OS | [linux] iptables 명령어 매뉴얼(options) | hooni | 2003.04.23 | 11333 |
1068 | System/OS | [linux] 간단한 NAT 설정 script | hooni | 2003.04.23 | 12595 |
1067 | System/OS | [linux] 랜카드 2개 설정 & iptables 로 사설 ip.. | hooni | 2003.04.23 | 14730 |
1066 | System/OS | [linux] apache, php, jsp 환경설정하기.. | hooni | 2003.04.23 | 15230 |