Contents

조회 수 28082 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
텍스트 한줄 읽기
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;


?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
745 Develop [io] Apple Watch, Today Extension 앱ID 설정 hooni 2016.04.20 784
744 Develop [ios] Did UIScrollView End Scrolling? hooni 2016.04.19 1009
743 Develop [ios] How To Use UIScrollView to Scroll and Zoom Content (Using Swift) file hooni 2016.03.23 7285
742 Develop [ios] How To Use UIScrollView to Scroll and Zoom Content (Using Objective-C) file hooni 2016.03.23 1595
741 Develop [js] AngularJS 란? file hooni 2015.11.26 877
740 Develop [php] 한글 문자열 자르기 (utf-8) hooni 2015.11.10 1309
739 Develop [c] 한글 문자열 출력 hooni 2015.11.10 1667
738 Develop [ios] NavigationController 에서 왼쪽(back) 버튼 후킹하기 hooni 2015.10.23 1172
737 Develop [ios] ViewController Push할 때 애니메이션 효과 hooni 2015.10.23 862
736 Develop [linux] CentOS Apache 웹서버에 HTTPS 적용 hooni 2015.10.23 775
735 Develop [c] 기막힌 정렬 코드 ㅋㄷ file hooni 2015.10.13 799
734 Develop [ios] 상위 ViewController 가져오기 hooni 2015.10.12 945
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 ... 71 Next
/ 71