Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
User Journal

Journal Ashtead's Journal: Since the lameness filter wouldn't let me post it

On wanting to show some longer C program code, I got the "too many junk characters" -- well the characters are just the ones they should be, since it is OK for the compiler. The lameness filter sez otherwise.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
FILE *fpo;
char *exstring;
int escount;
int j;

escount = 10;
for(j = 1; j<argc; j++) escount += strlen(argv[j]) + 2;

exstring = malloc(escount);

strcpy(exstring, "(" );
for(j = 1; j<argc; j+=1)
{
strcat(exstring, argv[j]);
strcat(exstring, " " );
}
strcat(exstring, ")" );

fpo = fopen("kcal.c", "wt");

fprintf(fpo,
"#include <stdio.h>\n"
"#include <math.h>\n"
"int main() \n"
"{\n"
" double r;\n"
" r = %s;\n"
" printf(\"Result of %%s = %%G\\n\", \"%s\", r); \n"
"}\n\n",
exstring, exstring);

fclose(fpo);
free(exstring);

system("cc -o kcal kcal.c -lm");
system("./kcal");
return(0);
}

But I can show this in the Journal at least.

This discussion has been archived. No new comments can be posted.

Since the lameness filter wouldn't let me post it

Comments Filter:

Math is like love -- a simple idea but it can get complicated. -- R. Drabek

Working...