My code
#include <stdio.h> #define FILENAME "m_6" int main() { float f; FILE * file; // read values if ( ! (file = fopen(FILENAME,"r"))) return 1; while ( fread( &f, sizeof(float), 1, file )) printf("%en", f); fclose( file ); }
When I compile with gcc gcc -c n1.c -o n1
and try to run it I got
bash: ./n1: cannot execute binary file: Exec format error
File m_6 and n1.c were executed on the same machine.
3.13.0-76-generic #120-Ubuntu SMP Mon Jan 18 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
How to solve this?
Advertisement
Answer
gcc -c
compiles source files without linking.
Cancel -c
from from command.