I have two problems:
-What is the use of "wb" and "rb" mode in C file managing.
-I want to know about CAST operator in C and where it is applied ?
please let me know.
"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.
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.
Thanks for your answer rbobitts.
But I have some confusions
Such as
1)When we use "wb" and "w"? actually what is difference between that twos? Same question about "rb" and "r".
Please let me know.
wb is write binary, which writes a stream of bits into the file, and w is just write, which is probably ASCII. Same with r and rb. For example, say that an ASCII A is represented by the binary string
011010101 (It's not, but bear with me)
using w, you would write an A in the file.
using wb, you would write 011010101 in the file.
Again, binary writes the literal binary information, and wirte writes teh higher level representation As always, I hope that helped!
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
Just to add to what ever that has been put across.
When you write details in a file using the ASCII mode "w" instead of "wb", all non printable symboys (eg '\n') etc will take their action instead of just being written....
if the same operation were to be written in Binary mode "wb" the information is stored as-it-is without the action taking place.
well!i know about "wb" and 'w'.
wb=in this mode file will be open in binary format and in write mod.
in accessing binary files,the compiler performs no traslation of the newline(or any other)characters at all.Bytes are stored or retrieved as they appear in the stream.thus binary format is useful where files have no line structure(e.g.,executable files), or where each byte must be preserved the way it is,without compiler-determined interpretations.there are other options:"rb","ab","ab+" etc.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.