Help??

Aoun13

Chairman of Selectors
Joined
Apr 2, 2008
Location
Rawalpindi (Pak)
Profile Flag
Pakistan
Online Cricket Games Owned
  1. Don Bradman Cricket 14 - Steam PC
Can anybody help me in finding the logical error,I am not able to withdraw and deposit money in this C and C++ bank management program.
I am attaching the code file.
 

Attachments

  • Bank1.txt
    13.6 KB · Views: 18
Last edited:
I am working on Visual C++ and I have been taught that I can use both printf or cout.
All things are working fine except the withdraw and deposition option.
 
Last edited:
Not wanting to be offensive, :p But that is stupid on your course / institution's part. printf was used in C, cout for C++.

I think if we add stdio.h then we can use printf and if we add iostream.h then we can use cout but both are valid

send2yaari added 3 Minutes and 18 Seconds later...

I can work with both cout and printf but I am making this with cout because it will differ my code from other student and so no one will cheat.;)
 
Last edited:
Yup please help me urgently I need to submit it by tomorrow,its also command prompt based.
 
The program crashes on a deposit (and I assume on withdrawal as well). In your ddepo() method the pointer to the account (dptr) hasn't been initialized. Hence it isn't pointing to any account. I'm not sure why your program doesn't crash...
 
so what can I do now to make it correct.
 
so what can I do now to make it correct.
Personally I would pass in the found account to the ddepo function. Since in the deposit() function you go through the linked list and find the correct account to deposit. In fact, you have to do that because ddepo has no notion of account number.

Do you understand the problem? It should be a simple fix if you wrote the program in the first place. ;)
 
I didn't understand buddy,actually I am fairly new in programming could you please correct it for me.
 
Simple answer:

Modify your ddepo and dwith methods to contain a node * parameter. You'll need to rearrange the definitions at the top (or better yet, move them to a header file):

Code:
void dwith(node *dptr);
void ddepo(node *dptr);

Then in the function definition, just remove the local dptr variable and it should point to the other one.

Expanded answer:
You are storing a linked list of dnode items that contain data about the account number, balance, and other information. In your deposit() method, you are taking input about the account number and then doing a linear search through the linked list of all accounts to determine which dnode to use. Once you do that search, though, you need to pass that information to ddepo/dwith. Otherwise, ddepo/dwith doesn't know which account to collect a deposit for/credit a withdrawal from.
 
I'll try what you have post and I can't move them to header file as in this semester we are not allowed to work with header file.
I have to make all in .cpp format.

send2yaari added 3 Minutes and 27 Seconds later...

I have done what you have said but my program is now giving 29 errrors
Code:
Bank1.cpp
D:\PRG\CMD\CMD2\Bank1.cpp(18) : error C2065: 'node' : undeclared identifier
D:\PRG\CMD\CMD2\Bank1.cpp(18) : error C2065: 'dptr' : undeclared identifier
D:\PRG\CMD\CMD2\Bank1.cpp(18) : error C2182: 'dwith' : illegal use of type 'void'
D:\PRG\CMD\CMD2\Bank1.cpp(19) : error C2182: 'ddepo' : illegal use of type 'void'
D:\PRG\CMD\CMD2\Bank1.cpp(20) : error C2182: 'dcurrent_with' : illegal use of type 'void'
D:\PRG\CMD\CMD2\Bank1.cpp(21) : error C2182: 'dcurrent_depo' : illegal use of type 'void'
D:\PRG\CMD\CMD2\Bank1.cpp(22) : error C2182: 'deposit' : illegal use of type 'void'
D:\PRG\CMD\CMD2\Bank1.cpp(23) : error C2182: 'withdrawal' : illegal use of type 'void'
D:\PRG\CMD\CMD2\Bank1.cpp(30) : error C2378: 'node' : redefinition; symbol cannot be overloaded with a typedef
D:\PRG\CMD\CMD2\Bank1.cpp(31) : error C2143: syntax error : missing ';' before '*'
D:\PRG\CMD\CMD2\Bank1.cpp(31) : error C2501: 'node' : missing storage-class or type specifiers
D:\PRG\CMD\CMD2\Bank1.cpp(31) : error C2501: 'dstart' : missing storage-class or type specifiers
D:\PRG\CMD\CMD2\Bank1.cpp(31) : error C2501: 'dtemp' : missing storage-class or type specifiers
D:\PRG\CMD\CMD2\Bank1.cpp(78) : error C2065: 'dprev' : undeclared identifier
D:\PRG\CMD\CMD2\Bank1.cpp(78) : error C2100: illegal indirection
D:\PRG\CMD\CMD2\Bank1.cpp(79) : error C2059: syntax error : ')'
D:\PRG\CMD\CMD2\Bank1.cpp(86) : error C2227: left of '->num' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(87) : error C2227: left of '->num' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(91) : error C2227: left of '->dtitle' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(93) : error C2227: left of '->dfname' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(95) : error C2227: left of '->dlname' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(97) : error C2227: left of '->dtel' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(101) : error C2227: left of '->bal' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(102) : error C2227: left of '->bal' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(107) : error C2227: left of '->dnext' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(110) : error C2440: '=' : cannot convert from 'int *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\PRG\CMD\CMD2\Bank1.cpp(111) : error C2227: left of '->dfname' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(111) : error C2227: left of '->dfname' must point to class/struct/union
D:\PRG\CMD\CMD2\Bank1.cpp(111) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

Bank1.obj - 29 error(s), 0 warning(s)
 
Yahoo!!
I have done it:banana2
I am so happy.
it's working now actually I was pointing dptr but all data was there in dtemp as I interchange dptr with dtemp in ddepo,my program start working
Hohoho!!!:happy
 
Personally I would pass in the found account to the ddepo function. Since in the deposit() function you go through the linked list and find the correct account to deposit. In fact, you have to do that because ddepo has no notion of account number.

Do you understand the problem? It should be a simple fix if you wrote the program in the first place. ;)
You hit the nail on the head here. ;)

Glad to know its been solved!
 

Users who are viewing this thread

Top