Develop
2013.04.23 15:40
[c++] mfc 파일 한줄씩 읽기.. ㅋㅋ
조회 수 28721 댓글 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;
-
[ios] 코코아 프레임워크(Cocoa Framework) 기본적인 내용~
-
[ios] Objective-C 특정 문자 찾아 제거하기
-
[ios] DJBros. (DJ요맨~)
-
[c] C로 구현한 CGI - 계산기 (링크리스트, 스택, 이진트리)
-
[c++] mfc 파일 한줄씩 읽기.. ㅋㅋ
-
[js] JSON 컨트롤.. 재귀호출로 값 출력하기
-
[ios] NSMutableString 문자열 패턴 교환
-
[python] DJI Tello 드론 코딩 (프로그래밍)
-
[ios] Objective-C 문자열 잘라서 배열(NSArray)에 넣기
-
[ios] 소소한 팁 (Rect,Point,Path,URL 등)
-
[ios] iCloud관련 저장 디렉토리
-
[ios] 테이블뷰셀/뷰에 배경 패턴 넣기..