Link to home
Start Free TrialLog in
Avatar of luna621
luna621

asked on

Won't print correct format

Hello, there are 2 problems with my display to user:

1. When I exit the program, it writes to a file called records.txt.  This is what saves the first time I run the program:
    http://www2.hawaii.edu/~lilyllam/C++/records_1st_time.txt.  This is what saves the second time: http://www2.hawaii.edu/~lilyllam/C++/records_2nd_time.txt.  
    Notice there are extra newlines and $ sign:

John Smith
                 <---------------- extra line
134 Street
AAA, BB$
$               <---------------- extra $ sign
374-5748
                 <---------------- extra line
1983
Jane Doe
57-4738 Star
USA$
385-7483
1956


because of the extra lines, when I call the printAllRecords(), the formating is very off :(

-and-

2. debug is a global variable that holds the following: 0 = no debug mode, 1 = debug mode.  debug mode simply prints a message to the user stating what the
    function is currently doing, and other debugging output, etc.  Below is my printDebugMessage that will display only if (debug == 1):


void llist::printDebugMessage(char *msg)
{
    if ( debug == 1 )
    {
        cout << "\n\n*********************************\n"
                    "          DEBUG MODE ON          \n"
                    "*********************************\n\n";
        cout << msg << endl;
    }
} // END printDebugMessage()

------------------------------------------------------------------------------------

Full Source Code here: http://www2.hawaii.edu/~lilyllam/C++/


Thank you!
Avatar of Dariuzk
Dariuzk

Hi,
>          if(line[strlen(line) - 2] == '$')
>            {
>                temp -> address[strlen(temp -> address) - 2] = 0; //remove the $ and the 'newline', too
>                break;
>            }
you remove only $ signe here!
string is array of char, by = you asign 1 char it mast be '\0'!
or you can write  strcpy(temp -> address, "");
ASKER CERTIFIED SOLUTION
Avatar of nonubik
nonubik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of luna621

ASKER

Thank you nonubik!!  That did the trick.  But, I still can't figure out why my debug message isn't displaying.  Maybe I have to pass the debug as a parameter?
Avatar of luna621

ASKER

Updated code: http://www2.hawaii.edu/~lilyllam/C++/

I'm currently trying to get the debug message to work.
Avatar of luna621

ASKER

I tried printing the debug value in the llist.cpp's printAllRecords(), and the value was -85782795.  Somehow, it's not getting the value from the main()...
Avatar of luna621

ASKER

Ok, nevermind.  I fixed it.  Seems like I made the setDebug(), but never used it?!!  Now it works wonderfully :D

Awarding points...