Contents

Views 28610 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
텍스트 한줄 읽기
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
No. Category Subject Author Date Views
1029 PPT 삼성페이(Samsung Pay) 구조 file hooni 2016.09.09 1016
1028 Develop [android] Android N requires the IDE to be running with Java 1.8 or later 오류 hooni 2016.08.30 937
1027 Develop [c] 파일명 또는 특정 패턴을 적용 file hooni 2016.08.03 879
1026 Develop [ios] Crashlytics, Fabfic 설치/설정 hooni 2016.07.21 833
1025 Develop [ios] 새로 만들고 있는 DateMemo file hooni 2016.07.12 722
1024 Etc 영어. 반드시 외워야 할 영어 숙어 2 file hooni 2016.07.07 6423
1023 Etc 영어. 반드시 외워야 할 단어 file hooni 2016.07.07 2066
1022 Develop [ios][swift] 초간단 카달로그 앱 (Catalog App) file hooni 2016.06.27 7282
1021 Develop [ios][swift] 초간단 To-do Memo file hooni 2016.06.27 1176
1020 Develop [ios][swift] 초간단 TableView 샘플 file hooni 2016.06.27 844
1019 Develop [ios] 웹뷰 history.back() ㅋㄷ file hooni 2016.06.27 2020
1018 Etc 플라스터(Plaster) 수업 내용 secret hooni 2016.05.24 0
Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 ... 98 Next
/ 98