GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #11  
Old 08-Nov-2004, 09:22
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by fwongmc
The above is my new code.I get stuck with the calculations



I did tried one night and I cannot figure out what's the problem,can you help me to debug my program? I will be very pleased if you do so.


You are given a test case. Did you run it? What did you get?

I feel that the best way to debug a program is to feed it data and see if it gives expected results.

(The program listing of your previous post has error(s) that prevent it from compiling.)

Before you debug the calculations, I think you should make sure that the calculation routine is getting the data that you expect it to have.

So...

put printf(), showing the values of the arguments num1, num2, etc., in the main program just before calling the encrypt/decrypt function.

Then, at the beginning of encrypt(), put a printf showing the value if the argument that it was called with, and put a printf() just before the return statement, showing the return value.

This is called the "top-down" approach. If you prefer the bottom-up approach, then make a separate program that only has main(), encrypt() and check_div().

In your main program set e, n, d and num1 to the values that you want (no user input required for this test program). Call encrypt and see what the return value is. Does it match the test case? If you can't see what the problem is, show us what you did, what you expected to get, and what you got. It won't help you very much for us to debug your program, but we will be more than happy to try to help you understand how to debug and to understand what's happening in a program.

Either the top-down or the bottom-up approach is viable, pick one.

Regards,

Dave
  #12  
Old 08-Nov-2004, 23:15
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,335
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
I see we've been wasting our time. After all this you
1) did not remove any scanf()functions
2) added a function that is not defined: fflush(stdin);

The C standard states that fflush() is undefined for input. You therefore should not use it because it is not guaranteed to work.

If you're instructor is teaching you to flush stdin, I highly question his abilities. He is teaching very bad habits and bad programming techniques, all of which you will find hard to break and when they don't work, you will spend days trying to figure out why.
__________________

During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence?
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TUTORIAL] Calling an external program in C (Linux) dsmith C Programming Language 4 22-Apr-2005 14:30
Anyone can write a program code for this??? chriskan76 C Programming Language 1 19-Oct-2004 21:25
Need help with a C program (Long) McFury C Programming Language 3 29-Apr-2004 21:06
error during program rjd72285 C++ Forum 0 11-Nov-2003 19:49
one program access another? dgoulston C++ Forum 1 07-Oct-2003 12:26

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:36.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.