LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C++ files (https://www.linuxquestions.org/questions/programming-9/c-files-389798/)

sajith 12-06-2005 08:59 AM

C++ files
 
hai sir

i have doubt in File operations in C++

write a program to add items to a file and display items from it

it will not work properly

it is added items into file and specified datafile is not created

when it dispaly items it only display the last entery that is added to the file (the while loop is not used case)


the read() function is used in while loop it will not display anything


sir please give me solution for this problem

graemef 12-06-2005 09:08 AM

Writing to a file normally replaces the contents of the file. That could be your problem. Although without any more information it is difficult to be certain.

I'd suggest that you attack your problem in stages.
  • Create a file using your favourite editor
  • then get your code to read the data in.
  • Then look at how you can modify the contents of the file

graeme

dmail 12-06-2005 09:28 AM

Quote:

...it is added items into file and specified datafile is not created

when it dispaly items it only display the last entery that is added to the file ..
is the file created then?
are you opening and shutting the file after ever loop?
whats your file open flags?


All times are GMT -5. The time now is 05:24 PM.