Created
July 21, 2015 18:22
-
-
Save rplantiko/18e8e859175f93454550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "fcgi_stdio.h" | |
#include <unistd.h> | |
void print_numbers( double* numbers, int n) { | |
for (int i=0;i<n;i++) { | |
printf("%s%.4lf",i>0?",":"",numbers[i]); | |
} | |
printf("\r\n"); | |
} | |
void do_header() { | |
printf("Content-type: text/plain\r\n\r\n" | |
"pid: %d\r\n", getpid()); | |
} | |
int main (int argc, char** argv) { | |
double x[12] = { 36.7858,68.0403,87.9978,106.0944,127.2410,159.4316,216.7858,248.0403,267.9978,286.0944,307.2410,339.4316 }; | |
while (FCGI_Accept() >= 0) { | |
do_header( ); | |
print_numbers( x, 12 ); | |
} /* while */ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See http://stackoverflow.com/questions/31525028/printf-swallowing-bytes-in-fcgi-mode
Output using the format specifier %lf will not be performed by programs in fastcgi. When changing the %.4lf to %.4f in the above example, the doubles will be printed as expected.