vendredi 11 septembre 2015

Opening a file in C

I looked at many examples before I wrote this, and I know many languages and clearly understand the syntax and what is going on in the code I listed below, however, when I compile my program for example:

gcc -o /sbin/"name" readfile.c

I get the following error:

enter image description here

This makes no since to me since my code clearly includes #include <stdio.h> which defines the FILE as referenced here ---- stdio.h.

//PROGRAM (readfile.c)

#include <stdio.h>

int main(){
    FILE *fp;
    fp = fopen("dummy.txt","w");
    fprint(fp, "testing...\n");
    fclose(fp);
}

//FILE (dummy.txt) *is in the same directory

Hello World



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire