this might be a stupid mistake but here it goes
I made a simple program that is supposed to write "1234" to a .txt file then it reads it back to you (why would this be useful, it's not, it is just a test). Ok so it writes to the file but it doesn't read from the file it just reads:
2293520
please help.
here is the codeCode:#include <stdio.h> int main() { int num1[10]; FILE *fp; fp = fopen("database.txt","w"); if (fp == NULL) {nullfile();} fprintf(fp,"1234"); fp = fopen("database.txt","r"); if (fp == NULL) {nullfile();} fscanf(fp,"%d",num1); printf("%d",num1); getch(); } int nullfile() { printf("file cannot be found"); getch(); return 0; }



LinkBack URL
About LinkBacks


