trouble with files

closed account (iTkG1hU5)
hey I have been on this for a whole day. Why doesn't this even create the slucajni.bin file? This is C, not C++, I hope it is ok.
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#define BROJ_ZAPISA 20

int main (void){
FILE *iztok;
int i,n,br,j;
iztok = fopen("slucajni.bin","bw");
srand((unsigned) time(NULL));
for (i = 1; i <= BROJ_ZAPISA; ++i){
n=(rand() % 7) +2;
fwrite(&n,sizeof(n),1,iztok);
for(j=0;j<n;j++){
br=(rand()% 11) +150;
fwrite(&br,sizeof(br),1,iztok);
}

}
fclose(iztok);
return 0;
}
1
2
3
4
5
iztok = fopen("slucajni.bin","bw");
if(!iztok){
   perror("fopen");
   return 1;
}
fopen: Invalid argument
reading the manual
The mode string can also include the letter 'b' either as a last character or as a character between the characters in any of the two-character strings described above.
closed account (iTkG1hU5)
thanks
Topic archived. No new replies allowed.