I need to write the value that is read by the read function to a file . I have opened a file in main under a switch case statement. The error that i got is The code is unable to read data into an object . While reading itself I tried to display the content of the object . I didn't get any output for that and ofcourse it cannot write to the files 1 and 2.