"wb" means open a file for writing in binary mode. "rb" means open a file for reading in binary mode.
You'll see casts a lot in C, however they are actually not needed very often. You should think carefully about what you're doing and *why* you're using a cast, you'll often discover that you don't need a cast and that you were operating under a misconception.
Some reasonable uses of casts:
size_t foo=5;
printf("%lu\n",(unsigned long)foo);
Since there is no conversion specifier for size_t (the new standard changes this) you need a cast here to make printf happy.
int compare(const void *s1,const void *s2)
{
char *string1=(char *)s1;
char *string2=(char *)s2;
/* ... */
}
This could be a function to pass to the standard library function qsort(). Since qsort() doesn't know about the representation of the objects in the arrays it sorts, the parameters here must be "generic" pointers to void. The user, knowing about the objects in the array then needs to cast the void pointers the appropriate type before operating on them.
HTH,
Russ
bobbitts@hotmail.com