Develop
2013.04.23 15:40
[c++] mfc 파일 한줄씩 읽기.. ㅋㅋ
조회 수 28524 댓글 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;
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
373 | Develop | [android] SurfaceView를 이용한 애니메이션 ㅎㅎ | hooni | 2013.04.23 | 57704 |
372 | Develop | [android] Canvas를 이용해 이미지 확대/축소 하기 | hooni | 2013.04.23 | 60741 |
371 | Develop | [java] 입출력 스트림 1부 (문자) | hooni | 2013.04.23 | 15293 |
370 | Develop | [java] 입출력 스트림 2부 (바이트) | hooni | 2013.04.23 | 10295 |
369 | Develop | [java] 입출력 스트림 3부 (오브젝트) | hooni | 2013.04.23 | 17136 |
368 | Develop | [android] 디바이스(시뮬레이터) hosts 파일 수정하기 | hooni | 2013.04.23 | 31071 |
367 | Develop | [android] 개발 환경 세팅 따라하기 ㅋㅋ | hooni | 2013.04.23 | 40398 |
366 | Develop | [ios] 아이폰용 앱 오픈 소스들 | hooni | 2013.04.23 | 466915 |
365 | Develop | [doc] Json Framework 설치와 사용 | hooni | 2013.04.23 | 21918 |
364 | Develop | [ios] UDID와 UUID (디바이스의 Unique Identifier) | hooni | 2013.04.23 | 27337 |
363 | Develop | [ios] 푸시알림(APNS)에 대한 php 라이브러리 ㅋㅋ | hooni | 2013.04.23 | 16632 |
362 | Develop | [winmobile] 윈도우 모바일 간단한 테스트 코드 ㅋㅋ | hooni | 2013.04.23 | 17083 |