- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use the nul terminated string szfilebuffer inthe win32 function WriteFile(), and it appears to work OK, note however only 3 spaces are allowed (Buffer_Len-2:Buffer_Len) for ' 'C. When the file is written the Cr and Lf work fine, and I checked the location of the nul char and it is in char position Buffer_Len, exactly where it should be.
szfilebuffer(Buffer_Len-2:Buffer_Len) = ' 'C
The string ' 'C should require 5 spaces including the nul char as follows:
szfilebuffer(Buffer_Len-4:Buffer_Len) = ' 'C
I do not understand why3 spaces work for ' 'C?Any insight would be appreciated. Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Because the C-string' 'C is visible to the compiler, the compiler preprocesses the string and inserts the correct control characters in place of the ' ' and the ' ' at compile time. If you had built your string using ''//'r'//''//'n'//''C, you will find that you get a string 5 characters long (including the null) and you would not get the control characters you want, because the compiler cannot recognise the ' ' string as a unit because it is not visible as a unit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page