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 |
Tags
- dll
- VB.NET
- 인스톨
- 시리얼 통신
- 설치
- 파라미터
- SQL
- vb
- Delphi
- 초보
- MFC
- 기초
- Visual Studio 2005
- MySQL
- 데이터베이스
- PostgreSQL
- WIN32 SDK
- 입문
- SDK
- Firebird
- 소니
- c#
- xml
- 예제
- winsock
- 파이어버드
- 문자열
- 델파이
- Visual Basic
- 셋업
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