Write char pointer to a file, read file and check size? : <p>I'm trying to read a char pointer to a file, then check the size of that file. The file SHOULD be 256 bytes if I'm doing this correctly. I want to create a file that has the char* array fwrite into it, then check that file to see it's size and print out it's size in bytes. My code is down below.</p>

<p>ALSO, i should be writing chars into the peep, NOT INTEGERS, but I'm not sure how to do that.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
typedef struct {
    double price;
    char title[60];
} game;
void main(){

    FILE* fp = fopen("file.txt","w+"); //file.txt will be blockchain text file.

    char* peep = malloc(256);

    for(int i = 0; i&lt;256;i++){      // Populate array with 256 2's.
        peep[i] = 2;                //THIS SHOULD BE CHARACTERS, ONE CHARACTER PER INDEX
    }
    for (int i = 0; i &lt; 256 ;i++){   //Print array to verify if has 256 2 char.                             
        printf("%d %d\n",peep[i],i);
    }
    int j = sizeof(peep)/sizeof(peep[0]); //amount of elements in array.

    fwrite(peep,sizeof(peep[0]),sizeof(peep)/sizeof(peep[0]),fp); //Writes 256 chars to the array, all of the peep.
    long fsize = 0; //Size of the file after writing
    if (fp != NULL){
        fseek(fp,0,SEEK_END);
        fsize = ftell(fp); 
    }
    if (fsize != 256){
        printf("\nPEEP NOT FULL,size is %ld",fsize);
    }
   // fseek(fp,0,SEEK_SET); //Go back to start of file, since we were at the end.
}
</code></pre>
