akbsol
08-08-2007, 12:21 AM
Hi everyone,
I must be ignoring something really basic but please anyone tell me what is the problem with the following code. Its a simple program to create a temporary file containing all command line arguments one per line (seperated by CRLFs). The code compiles fine in VC++ but when the generated exe is run, it creates the file with command line arguments seperated by CRCRLFs (\r\r\n) instead of CRLFs (\r\n).
#include <stdio.h>
main(int argc, char *argv[])
{
FILE *f;
int i;
char g[] = "C:\\temp\\XXXXXX";
char *h;
char *mktemp();
h = mktemp(g);
f = fopen(h, "w");
for(i=0;i<argc;i++)
{
fputs(argv[i], f);
fputs("\r\n", f);
}
fclose(f);
}
Regards,
Akash
I must be ignoring something really basic but please anyone tell me what is the problem with the following code. Its a simple program to create a temporary file containing all command line arguments one per line (seperated by CRLFs). The code compiles fine in VC++ but when the generated exe is run, it creates the file with command line arguments seperated by CRCRLFs (\r\r\n) instead of CRLFs (\r\n).
#include <stdio.h>
main(int argc, char *argv[])
{
FILE *f;
int i;
char g[] = "C:\\temp\\XXXXXX";
char *h;
char *mktemp();
h = mktemp(g);
f = fopen(h, "w");
for(i=0;i<argc;i++)
{
fputs(argv[i], f);
fputs("\r\n", f);
}
fclose(f);
}
Regards,
Akash
