I defined a resource file in my Visual Studio 2008 C ++ project. The problem is that after receiving the resource data using the LockResource method, the resulting char buffer contains carriage returns and linear channels, where the source data contains only rows. For example, if the source string contains:
00 0A FC 80 00 00 27 10 00 0A FC 80 00 00 27 10
The resulting char * also contains a carriage return (0D):
00 0D 0A FC 80 00 00 27 10 00 0D 0A FC 80 00 00
I tried the following code to get rid of them, but this will result in a carriage return and line feed:
for (int i = 0; i < sz; ++i) { // Ignore carriage returns if (data[i] == '\n') continue; // ... }
How can I get rid of carriage returns, but leave newlines?
EDIT:
Make it more specific. I am writing a char buffer to a file:
std::ofstream outputFile(fileName.c_str()); for (int i = 0; i < sz; ++i) { // Ignore carriage returns // if (data[i] == '\r') continue; This leaves both CR and LF // if (data[i] == 0x0D) continue; This leaves both CR and LF if (data[i]) == '\n') continue; //This removes both CR and LF outputFile << data[i]; }
source share