pg_services.c
text/x-c++src
Filename: pg_services.c
Type: text/x-c++src
Part: 0
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#ifdef WIN32
// Open files in binary mode
#include <fcntl.h> /* _O_BINARY */
#include <windows.h>
#endif
int main(int argc, char* argv[])
{
FILE* f;
char buf[200], *line;
#ifdef WIN32 // Windows
#ifdef _MSC_VER
_set_fmode(_O_BINARY);
#endif // _MSC_VER
#endif // WIN32
f = fopen(argv[1], "rt");
if (f != NULL)
{
while ((line = fgets(buf, sizeof(buf), f)) != NULL)
{
/* ignore EOL at end of line */
if (strlen(line) && line[strlen(line) - 1] == '\n') {
line[strlen(line) - 1] = 0;
printf("\\n ");
}
/* ignore CR at end of line */
if (strlen(line) && line[strlen(line) - 1] == '\r') {
line[strlen(line) - 1] = 0;
printf("\\r ");
}
printf("%s\n", strrev(line));
}
fclose(f);
}
return 0;
}