Contents

Views 28513 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
525 Develop [ios] Objective-C에서 SQLite 사용하기.. file hooni 2013.04.23 14556
524 Develop [ios] Objective-C 프로퍼티의 strong, weak, assign file hooni 2014.03.17 4682
523 Develop [ios] Objective-C 프로퍼티의 ATOMIC / NONATOMIC 속성 hooni 2014.03.17 2998
522 Develop [ios] Objective-C 특정 문자 찾아 제거하기 hooni 2013.04.23 28065
521 Develop [ios] Objective-C 에서 자주 사용하는 수학 함수와 유용한 Define hooni 2014.08.08 1856
520 Develop [ios] Objective-C 문자열 조작 메서드 hooni 2013.04.23 26455
519 Develop [ios] Objective-C 문자열 잘라서 배열(NSArray)에 넣기 hooni 2013.04.23 29415
518 Develop [ios] Objective-C Types & Storage Capacity hooni 2015.07.22 1151
517 Develop [ios] NSString, RegularExpression Find/Replace hooni 2017.04.14 832
516 Develop [ios] NSString 간단한 정규식 사용법 hooni 2014.01.28 18218
515 Develop [ios] NSString URL Encode/Decode (인코딩/디코딩) hooni 2014.05.02 3412
514 Develop [ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ hooni 2015.06.26 654
Board Pagination Prev 1 ... 50 51 52 53 54 55 56 57 58 59 ... 98 Next
/ 98