G
gof
I'm pretty new to C++, and this seemingly simple thing is driving me
crazy. I'm trying to write a CGI script to serve images on the fly.
CGI requires the content to be sent through standard output, but since
cout and printf convert LF line endings to CRLF (I'm on Windows), the
resulting image ends up being corrupt.
Is there ANY way to get around this? It seems writing CGI scripts in
C++ on Windows is pretty much impossible.
Here's an example of what I'm trying to do:
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream in("in.png", ios::binary);
cout << "Content-type: image/png\n\n";
cout << in.rdbuf();
return 0;
}
crazy. I'm trying to write a CGI script to serve images on the fly.
CGI requires the content to be sent through standard output, but since
cout and printf convert LF line endings to CRLF (I'm on Windows), the
resulting image ends up being corrupt.
Is there ANY way to get around this? It seems writing CGI scripts in
C++ on Windows is pretty much impossible.
Here's an example of what I'm trying to do:
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream in("in.png", ios::binary);
cout << "Content-type: image/png\n\n";
cout << in.rdbuf();
return 0;
}