#include <stdio.h>
int main (int argc, const char * argv[])
{
FILE *fp;
fp=fopen("/Users/--------/Desktop/C.txt", "w");
putc("C", "/Users/-------/Desktop/C.txt");
fclose(fp);
}
Here is my simple code for writing the letter “C” into the textfile C.txt. I get the error code EXC_BAD_ACCESS every time I write it. Whats happeneing?
That’s not how
putcshould be used. Try:putclooks like this:You are passing a
char *instead of aFILE *.