Contents

Views 28651 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 Develop [jsp] Get방식, Post방식 전송 예제.. file hooni 2003.04.23 13806
1028 Develop [c++] 기초강좌 #01(입출력,영역지정) hooni 2003.04.23 11477
1027 Develop [c++] 기초강좌 #02(레퍼런스,메모리할당) hooni 2003.04.23 11486
1026 Develop [c++] 기초강좌 #03(함수의 매개변수 전달) hooni 2003.04.23 12141
1025 Develop [c++] 기초강좌 #04(클래스) hooni 2003.04.23 11875
1024 Develop [c] C로 구현한 CGI - 방명록 file hooni 2003.04.23 33513
1023 Develop [c] C로 구현한 CGI - 계산기 (링크리스트, 스택, 이진트리) file hooni 2003.04.23 28160
1022 Develop [c] C로 구현한 CGI - 달력과 날짜계산기 file hooni 2003.04.23 32501
1021 Develop [jsp] 유효성체크(Client, Server 에서) file hooni 2003.04.23 7472
1020 Develop [js] 키보드 아스키 코드 확인하는 간단한 소스 hooni 2003.04.23 7797
1019 Develop [js] 핫키(단축키) 구현방법 hooni 2003.04.23 7656
1018 Develop [js] 이미지 미리 로딩하기 hooni 2003.04.23 7041
Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 ... 98 Next
/ 98