Develop
2013.04.23 15:40
[c++] mfc 파일 한줄씩 읽기.. ㅋㅋ
Views 28623 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 |
---|---|---|---|---|---|
1029 | Develop | [ios] Facebook Cache 갱신하는 함수 | hooni | 2017.02.27 | 1319 |
1028 | Develop | [ios] Facebook SDK 로그인 설명 | hooni | 2017.04.19 | 1320 |
1027 | System/OS | Enable the Develop Menu in Safari | hooni | 2017.02.07 | 1328 |
1026 | Develop | [ios] UIWebView를 이용한 로컬 HTML 파일 표시 | hooni | 2015.01.02 | 1335 |
1025 | Develop | 사이버보안실무 발표자료 (2017.06.08) | hooni | 2017.06.05 | 1341 |
1024 | Develop | [js] 문자열에서 숫자만 걸러내기 (jQuery 안쓰고 정규표현식) | hooni | 2017.12.14 | 1350 |
1023 | Develop | [ios] APNS, Remote Push 사용자가 수신을 동의했는지 확인하기 | hooni | 2018.10.19 | 1363 |
1022 | Database | [mysql] ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. | hooni | 2017.12.15 | 1371 |
1021 | Etc | 영어. 반드시 외워야 할 문장 패턴 100개 | hooni | 2023.06.08 | 1373 |
1020 | PPT | [ppt] Macro for board game 발표자료 (@Team Study 2013.01.18) 1 | hooni | 2015.07.22 | 1375 |
1019 | Develop | [ios] 동영상 플레이어 샘플 (for PIP Player) | hooni | 2017.03.15 | 1394 |
1018 | System/OS | [linux] iptables 초간단 세팅 스크립트 | hooni | 2017.09.26 | 1398 |