Contents

Views 28515 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 [c++] mfc 윈도우에서 ODBC 사용하여 MDB파일 읽기.. ㅋㅋ file hooni 2013.04.23 9118
524 Develop 다운 받아서 테스트 해볼것.. hooni 2013.04.23 9137
523 Develop [php] URL/URI 관련 환경변수 hooni 2003.04.23 9146
522 Develop [c] 하노이탑 - 재귀함수 hooni 2003.04.23 9153
521 Develop [c++] RSA Sample 4 CPP hooni 2013.04.23 9181
520 Develop [c][java] 그래픽(graphic)관련 자료와 샘플코드.. file hooni 2013.04.23 9205
519 Develop [c] SetTimer() & KillTimer() & 일회용 Timer hooni 2013.04.23 9208
518 Develop [php] Laravel 5.4: Specified key was too long error file hooni 2017.12.04 9219
517 Develop [c++] mfc이용한 트레이아이콘(TrayIcon) 클래스 예제 프로젝트 file hooni 2013.04.23 9247
516 Develop [ios] In App Purchase 개발 hooni 2013.11.20 9262
515 Develop [c] 도메인 소켓(Unix Domain Socket) UDP file hooni 2013.04.23 9282
514 Develop [c] 전위 표기법으로 연산 예제.. file hooni 2013.04.23 9304
Board Pagination Prev 1 ... 50 51 52 53 54 55 56 57 58 59 ... 98 Next
/ 98