FILE *fp = fopen("file.txt", "w+"); fseek(fp,0,SEEK_END); int size = ftell(fp) + 1; // we have to account for the 0th position in the file