CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    May 2008
    Posts
    6

    fstream file.open

    Hello all,

    I have an invoice sort of program. The user enters in a command, and then a product and price, another command to enter in the product and its quantity. They then do a command to generate the invoice.

    Part of what i want to do is read in from a file. Now currently, i have got it doing this, if and only if, it is the users first attempt at reading the file in.


    here is my code. It should be noted that the user can type in any sequence of program commands (all starting with /), as long as product and it's prices (raw prices) are done first. Like i said this all works.

    Now the problem.

    If the user ran the program and typed in
    /read input.txt and input.txt existed all would be sweet

    but if they went
    /read bat.txt //bat.txt doesn't exist
    *here an error message saying such a file doesn't exist correctly appears*
    /read input.txt //input.txt does exist
    an error message would appear saying that the input.txt file doesn't exist.

    I am at a complete loss as to what is happening. I suspect it has something to do with the first file not being closed down properly, but i have placed that file.close() everywhere i can think of with no results.

    Any helpful suggestions please?

    thanks all
    tim
    Last edited by Timmeh041; May 27th, 2008 at 10:39 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured