CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: JasonBB

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Thanks

    I truly thank you guys for helping me out on this. The function seem to be working great-- I am just making some small tweaks to the code to make it fit in better with the rest of the program.
    ...
  2. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Basically, in this line:


    file_out.write(&buffer[0], x);

    I need to use a string instead of the vector<char>, somehow, but the function cannot take a string. i.e. If you look at the code...
  3. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    . . . Anyone?
  4. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Point taken, but I would rather protect both.
  5. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    I can't for security reasons (the software is for website security). Basically, though, it's:


    string my_function(string mystring){

    //changes
    //send to another function
    //changes
    //send...
  6. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    #include<string>

    #include<iostream>

    #include<fstream>

    #include<stdio.h>

    #include<vector>
  7. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Thanks for the the code, Joeman. I will be taking a closer look at that later to hopefully help me learn more about file I/O. But for now, the code I have is working, I just need to know how to...
  8. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    So, I added this:

    if(file_in.eof()){x = x-1;}
    after the for loop, and it seems to do the trick, but I don't know if that is a good option. What do you think?
    I still can't figure out how to...
  9. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    I'm sorry. You are correct. I changed that, and now it almost works. It is sooo close. It adds one extra character to the end of the file.

    here is the updated function:


    int processFile(char*...
  10. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Okay, forgive me but this will be a long post. The test.txt file looks like this for now (later on the real file will not have many line breaks-- if any-- and it will be much longer).



    When I...
  11. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Sorry, I didn't see your last post. Yes, I agree that I need to set this up better. Give me a few minutes and I'll rework this a bit before we dive in further.
  12. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    It appears to be the buffer. It reads in all of the character alright, but somehow some extra things are added to it.

    If you do this:

    cout << buffer[i] << endl;
    in the for loop, it looks...
  13. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Wait, then how do I modify the string with my function?
  14. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Ahead of you on that. Tried it and it didn't help. I am getting an extra char on each loop, it seems, so even if it reads in 350 chars, it outputs an extra char.

    I am poking around to see if I...
  15. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Thanks, Paul. I did this:



    #include<fstream>

    #include<stdio.h>

    #include<vector>
  16. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    I think I solved problem 2:


    #include<fstream>

    #include<stdio.h>

    #include<vector>

    usingnamespace std;
  17. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Duoas was right, file_in was opened twice. That got the code kind of working.

    Two things now:
    1) file2 (the first file_out) has extra characters at the end.

    I imagine that it is taking all...
  18. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Woah! I put this at the end of the loop:

    cout << file_in.eof() << "|" << file_in.tellg();
    and it is printing 0|-1 over and over.

    Here is an update on the code:



    #include<string>
  19. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    I've been using the debugger-- that is what brought up the runtime errors earlier. I tried adding this right after the file_in.open() statement, and it still went throught the loop:
    ...
  20. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    The FAQ itself is not insulting, this link is:
    http://www.parashift.com/c++-faq-li...st.html#faq-5.8
    Anyway. . .
    Now there are no errors, but nothing is happening. The console is just blank and...
  21. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Vague, but thank you.

    . . . Isn't the point of a forum to help you learn? I understand that one needs to learn to find answers, but at the stage I am at right now, I need someone to help me find...
  22. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    *sigh*
    I figured the code wasn't correct because it didn't run. I still don't know why, so I don't see what your talking about on that point. What is a pointer? I tried googling it and can't figure...
  23. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Then help me understand. What should the code be? So far I have gotten no information from you in four posts.
  24. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    . . . It's the same code Bluefox815 posted, just with different file names, and as suggested I changed file1 to file_in and file2 to file_out.


    You sound like a happy, optimistic guy. I am...
  25. Thread: File I/O help

    by JasonBB
    Replies
    51
    Views
    10,489

    Re: File I/O help

    Er, I figured that much about the error message. But how do I initialize the variable?

    And, yes, I probably should a more serious look at a tutorial, but for now I just want to finish the program.
Results 1 to 25 of 27
Page 1 of 2 1 2


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)