Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown conversion types in this program I'm meant to compile

I don't know how this C program I'm meant to compile works exactly. I'm compiling it on a MacBook so maybe that explains the unusual errors? Anyway the compiled program doesn't seem to be working correctly. When compiled, I get these:

ers.c: In function ‘evolve’:
ers.c:205: warning: unknown conversion type character 0xa in format
ers.c: In function ‘print_rule’:
ers.c:304: warning: unknown conversion type character 0xa in format
ers.c: In function ‘test_evaluate’:
ers.c:380: warning: unknown conversion type character 0xa in format

Which refer to these lines of code:

 if(i%100==0)printf("best on training set at iteration %d:  %g\%\n", i,100.0* population[bestinpop].acc);

printf("ACCURACY on training set %g\%\n\n", 100.0* r->acc);

printf("TEST ACCURACY %g\%\n", 100.0* r->acc);

I suspect it to be something to do with that %g type formatting.

Can anyone see what is being done wrong?

like image 741
Chucky Avatar asked Nov 19 '12 13:11

Chucky


2 Answers

The 0xa in ASCII encoding is the Line Feed character \n, so your errors are indeed coming from the "%\n" constructs

I assume that the original developer meant "%%" and not "\%" (to display '%' characters). But I don't believe that this program ever compiled on any platform.

BTW : %g is an alternative formatting character for double (output is same as %f or %e, depending on the double value).

like image 145
NiBZ Avatar answered Nov 01 '22 13:11

NiBZ


"%\n" is not a valid format specifier. If you need the % character to be part of the output you need to use "%%".

like image 30
hmjd Avatar answered Nov 01 '22 13:11

hmjd