Thread: Having trouble identifying whats wrong.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    FILE *ofp = fopen("roster.txt", "w");
    That is going to start with a new file every time (in effect) because it truncates the file when you open it to w mode.
    Code:
        fprintf(ofp, "%s\n", &temp_employee);
        fprintf(ofp, "%s", &new_employee);
    Neither of those two & should be there. You are also apparently trying to write the entire structure, instead of writing both names one at a time. You need either fwrite or something like new_employee.fname and new_employee.lname. Also note that you are writing new_ once and temp_ once. So if that was .fname and .lname, you'd be writing the .fname of one and the .lname of the other.


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    131
    Quote Originally Posted by quzah View Post
    Code:
    FILE *ofp = fopen("roster.txt", "w");
    That is going to start with a new file every time (in effect) because it truncates the file when you open it to w mode.
    I doubt that is going to be an issue during a dev/test stage especially with such a small output file. I never care if I overwrite output files during dev and test stages until I'm moving closer to finalizing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. whats wrong in this!!!!
    By chintugavali in forum C++ Programming
    Replies: 1
    Last Post: 12-19-2007, 03:55 AM
  2. whats wrong with this?
    By Hugo716 in forum C++ Programming
    Replies: 1
    Last Post: 05-26-2006, 11:52 PM
  3. whats wrong?!?
    By stuart_cpp in forum C++ Programming
    Replies: 7
    Last Post: 04-23-2006, 12:08 PM
  4. whats wrong with this? no errors but wrong result
    By InvariantLoop in forum C Programming
    Replies: 6
    Last Post: 01-28-2005, 12:48 AM
  5. Can anyone tell me whats wrong?
    By Dragoncaster131 in forum C Programming
    Replies: 2
    Last Post: 05-16-2004, 04:36 AM