Are you creating a makefile from your C program? The only reason I could imagine is the error message.
make: *** No targets. Stop
Error play
Here is how I could generate this message:
#include <stdio.h> #include <stdlib.h> int main() { FILE *fp = fopen("Makefile", "w"); fputs("all:\n\techo Done.\n", fp); system("make"); fclose(fp); return 0; }
This is expected to print:
make: *** No targets. Stop
I say predictably because the Makefile will be empty! This is because IO is buffered ...
Fixed version
So, I close the file before calling system() , which flushes the buffer ( fflush() also does the trick):
#include <stdio.h> #include <stdlib.h> int main() { FILE *fp = fopen("Makefile", "w"); fputs("all:\n\techo Done.\n", fp); fclose(fp); system("make"); return 0; }
Output:
echo Done.
Done
I used the C IO functions for clarity, but the same rules apply to <iostream> .
source share