Both r+ and w+ we can read ,write on file but r+ does not truncate (delete) the content of file as well it doesn’t create a new file if such file doesn’t exits while in w+ truncate the content of file as well as create a new file if such file doesn’t exists.
C language interview questions solution for freshers beginners placement tricky good pointers answers explanation operators data types arrays structures functions recursion preprocessors looping file handling strings switch case if else printf advance linux objective mcq faq online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c++ tutorials and pdf
7 comments:
if w+ truncates the contents of file ,then how w+ can b used for reading operation ?
w+ create and open file for reading and writing it can discards previous contents. it behaves like w with option of reading..
what does the following modes perform in c lang?
"r+" "a" "r"
and how many modes are there in c lang?
can u answer my query?
can u answer me????/
can u answer me????/
in file handling there are 5 modes mainly : r , w, a, w+ , r+ but there are some additional modes also available depending upon the type of file : text or binary . if you need to work on binary files the use b after above mode e.g rb,wb,ab,w+b,r+b. by default mode is text mode if needed then use t instead of b i.e w+t, rt etc.
Post a Comment