Contents

조회 수 28582 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
405 Etc [link] 유용한 사이트 링크. hooni 2013.08.19 71546
404 System/OS [linux] /etc/fstab 설정 방법.. ㅋㅋ hooni 2013.04.23 12140
403 System/OS [linux] apache, php, jsp 환경설정하기.. hooni 2003.04.23 15295
402 System/OS [linux] APM(apache, php, mysql) + gd 설치순서.. hooni 2003.04.23 18920
401 System/OS [linux] awk 명령어 hooni 2014.03.11 5028
400 System/OS [linux] CentOS 6.5 에서 "Bringing up interface eth0: Determining if ip address 121.78.127.197 is already in use for device eth0..." hooni 2014.04.05 4954
399 System/OS [linux] CentOS 6.x Cati 설치 (yum) hooni 2014.01.17 48656
398 System/OS [linux] CentOS Apache Httpd에 https 적용 hooni 2014.03.05 4576
397 Develop [linux] CentOS Apache 웹서버에 HTTPS 적용 hooni 2015.10.23 907
396 System/OS [linux] CentOS 에 APM 설치하기 hooni 2015.01.02 1899
395 System/OS [linux] CentOS 터미널 언어 설정(한글/영어) hooni 2013.12.22 18615
394 Develop [linux] crond 사용법.. ㅋㅋ hooni 2013.04.23 7264
Board Pagination Prev 1 ... 60 61 62 63 64 65 66 67 68 69 ... 98 Next
/ 98