Develop
2013.04.23 15:40
[c++] mfc 파일 한줄씩 읽기.. ㅋㅋ
조회 수 29521 댓글 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;
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
1081 | System/OS | [linux] ipchains 사용예(패킷 필터링) | hooni | 2003.04.23 | 15017 |
1080 | System/OS | [linux] ipfwadm를 이용한 패킷필터링(구버전) | hooni | 2003.04.23 | 13950 |
1079 | System/OS | [windows] 98/ME 속도 빠르게 튜닝(부팅,메모리,레지스터) | hooni | 2003.04.23 | 51540 |
1078 | System/OS | [windows] 도스 사용 팁 | hooni | 2003.04.23 | 18632 |
1077 | System/OS | [windows] 여러가지 활용 팁 | hooni | 2003.04.23 | 20738 |
1076 | System/OS | [windows] 배치(bat)파일 제작 방법 | hooni | 2003.04.23 | 17867 |
1075 | System/OS | [linux] 패킷 스니퍼링 | hooni | 2003.04.23 | 17201 |
1074 | System/OS | [linux] 패킷의 소스 주소 바꾸기 | hooni | 2003.04.23 | 19536 |
1073 | System/OS | [linux] iptables 명령어 매뉴얼(options) | hooni | 2003.04.23 | 12623 |
1072 | System/OS | [linux] 간단한 NAT 설정 script | hooni | 2003.04.23 | 13267 |
1071 | System/OS | [linux] 랜카드 2개 설정 & iptables 로 사설 ip.. | hooni | 2003.04.23 | 15593 |
1070 | System/OS | [linux] apache, php, jsp 환경설정하기.. | hooni | 2003.04.23 | 16151 |