954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HELP!!!! can't locate the error

I have an assignment in Modular programming..
Have been able to make the program work... the lil problem am having now is that when i try to load the file i created, it keeps adding the memory location. Moe like it's adding an additional data insead of just loading the initial file.. can anyone help me with this?..
have attached a copy of my assignment to this message.. was trying to zip it but the school server was kinda acting funny..
thanks in Advance

PS: it's written in VC++ 6 so i don't know if it can be a problem for Vc++2008...
Attachments prompt.cpp (0.5KB) prompt.h (0.24KB) vcdDB.cpp (2.75KB) vcdDB.h (1.33KB) vcdrec.cpp (1.06KB) vcdrec.h (0.59KB) vcdmain.cpp (3.46KB)
dapcigar
Newbie Poster
6 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

1) prompt.h and prompt.cpp -- you need to specify function return values.

2) program is using uninitialized struct member in function Add_vcd(). You can fix that problem by adding a class constructor to the structure which initializes it.

struct vcdDB_T{
       vcdRec_T vcdRecords[maxSize];
       int vcdIndex;
public:
    vcdDB_T() {vcdIndex = 0;} 
};


There appear to be other problems too, such as displaying junk records.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thanks.. But, When i run the program, my prompt is working fine.. my guess is that am missing something in the vcdDB.h and vcdDB.cpp.

dapcigar
Newbie Poster
6 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Well you do use eof() in a control loop, which is bad
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351

eof() is a state (the result of a past failure), not a prediction (of a future failure).

That is, if you have a 10 char file and read 10 chars, then eof() will NOT be true. It's only when you try to read (and fail) to read the 11th char that eof() will become true.

The corrollary of all this is that ALL your file read functions should check their return result to see that they succeeded.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You