Contents

조회 수 28535 댓글 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;


?

  1. [java] Sieve of Eratosthenes (에라토스테네스의 체)

  2. [sql] 간단한 통계 서브쿼리 예제..

  3. [js] 사진첩에 쓸 내용 - 마우스 오버로 바꾸기

  4. [js] 폼(form) 전송시 중복 클릭 방지 간단한 구문

  5. GSM에서 음성이 실리는 과정 요약..

  6. [ajax] 샘플 코드와 한글처리에 대한 간단한 설명

  7. [doc] 정보보호학술대회 논문지 ㅋㅋ

  8. [c] 전위 표기법으로 연산 예제..

  9. [c] 프로그램 코드(c/c++)를 html 파일로 변환

  10. [c] 구조체 배열 예제 (학생 성적 계산)

  11. [c] 숫자 맞추는 게임..

  12. [js] php의 number_format() 함수와 같은.. ㅋㅋ

Board Pagination Prev 1 ... 28 29 30 31 32 33 34 35 36 37 ... 98 Next
/ 98