0

I have an array called dicevalues which contains 100 random int values from 1 to 6. It is newly randomly generated everytime I run the program. I make each value into a char, so I can write it properly into a file. I want to set the pointer of the file to the beginning, so if I run the program again it overwrites the old data. However this doesn't seem to work. Everytime I run the code it only appends. Heck, no matter what values I set fseek to it only appends without overwriting anything.

fseek(fd,0,SEEK_SET);
for(i=0;i<100;i++){
    dicechar = (char) (dicevalues[i]+48);//makes a char out of the int
    fwrite(&dicechar,sizeof(char),sizeof(augenchar),fd);
};

What am I doing wrong?

0 Answers0