Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 기초
- VB.NET
- 셋업
- MySQL
- xml
- 소니
- c#
- 설치
- 데이터베이스
- 초보
- Firebird
- 입문
- 인스톨
- Visual Studio 2005
- dll
- 문자열
- WIN32 SDK
- 파라미터
- MFC
- 델파이
- 시리얼 통신
- Visual Basic
- 파이어버드
- Delphi
- SDK
- vb
- winsock
- 예제
- PostgreSQL
- SQL
Archives
- Today
- Total
프로그래밍 노트
WriteFile()를 사용할때 줄바꾸기(행바꾸기) 본문
The Stupidity of Newlines
In the ASCII table above, there are two bytes that could legitimately be treated as indicating "this line of text is over. start a new one.":- 0x0A, '\n', Line Feed. This is the standard C way to indicate a new line is starting.
- 0x0D, '\r', Carriage Return. This actually moves the cursor back to the start of the line.
Sadly, every major computer system nowdays treats newlines differently.
In DOS/Windows, '\r' only moves the cursor horizontally to the start of the line, and '\n' only moves the cursor vertically down. This means to really start a new line of text in a DOS/Windows file, you need to use "\ \ ", like this:
------------------------------------------------------------------------
BOOL WriteLine(CString csLog)
{
DWORD dwLength;
CString csPrint;
BOOL fRet;
csrint.Format("%s\r\n", csLog);
fRet = WriteFile(hLog ,(LPCVOID)csPrint, csPrint.GetLength(), &dwLength, NULL);
return fRet;
}
------------------------------------------------------------------------
위에 소스의 빨강 부분처럼 써주어야지만
줄이 바뀌어 파일에 씌어지는군요.
Comments