Views 28513 Votes 0 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
309 System/OS HTTPS와 SSL 인증서 file hooni 2014.03.11 7544
308 System/OS [mac] 맥OSX에서 NTFS 쓰기 기능 활성화 hooni 2014.03.12 4284
307 System/OS [mac] 맥(OSX)에서 NTFS, 윈도우에서 HFS+ 사용하기 file hooni 2014.03.12 5115
306 Develop [ios] UDID 사용 제한에 따른 대안들 hooni 2014.03.13 3964
305 Develop [ios] Objective-C 프로퍼티의 ATOMIC / NONATOMIC 속성 hooni 2014.03.17 2998
304 Develop [ios] Objective-C 프로퍼티의 strong, weak, assign file hooni 2014.03.17 4682
303 Develop [ios] Using protobuf(Protocol Buffers) on iPhone (iOS) file hooni 2014.03.20 4982
302 Develop [ios] 유용한 매크로 hooni 2014.03.26 3652
301 Develop [ios] iOS 7 이상 UIBarButtonItem 여백 file hooni 2014.03.27 4047
300 Develop [ios] SQLite 사용하기(튜토리얼) + 샘플코드 file hooni 2014.03.28 3695
299 Develop [ios] CoreData 사용하기 (튜토리얼) hooni 2014.03.28 3174
298 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 4835
297 System/OS [linux] resolv.con 초기화 되는 문제 hooni 2014.04.05 4614
296 Develop [ios] UITableView 특정 Row만 Update hooni 2014.04.08 4772
295 Develop [ios] UIWebView 캐쉬 삭제 hooni 2014.04.08 3660
294 Develop [ios] DatePicker iOS 6.x 이하 디자인. file hooni 2014.04.10 4054
Board Pagination Prev 1 ... 53 54 55 56 57 ... 74 Next
/ 74