Conservative. Idaho. Software engineer. Historian. Trying to prevent Idiocracy from becoming a documentary.
Email complaints/requests about copyright infringement to clayton @ claytoncramer.com. Reminder: the last copyright troll that bothered me went bankrupt.
"And we know that all things work together for good to them that love God, to them who are the called according to his purpose." -- Rom. 8:28
On linux fopen takes a mode argument, like "r", so maybe that's the problem?
ReplyDeleteHmm. this worked for me on Windows 10 with Visual Studio. (I skipped a bit, like closing the file).
ReplyDelete#include >stdio.h>
#include >stdlib.h>
int main(int argc, char *argv[])
{
char *line;
FILE *source;
line = malloc(2000);
source = fopen(argv[1], "r");
if (source != NULL)
{
fgets(line, 2000, source);
puts(line);
}
return 0;
}
It's been a long time but did you remember to #include ?
ReplyDeleteI also think you have to give a mode to fopen(), not just a filename.
ReplyDelete