File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes C / C++ and the fly likes Help needed: C Code freezes mid execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Help needed: C Code freezes mid execution" Watch "Help needed: C Code freezes mid execution" New topic

Help needed: C Code freezes mid execution

Shiveen Pandita

Joined: Jul 30, 2012
Posts: 25

Hi, I'm working on a network queue simulator. Although, I'm not really well versed or experienced in programming in C, I was able to get together the following code:

The problem I keep on getting is that sometimes the code works just fine (VERY RARELY) while other times, it works fine for few iterations of the on timer (ton) but stops short of completing. This is actually an assignment for a networking lab.

ANY kind of help is appreciated. Just any. Even if you point me in right direction, that'll be heaps good. Thanks!
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45360
As usual, you cannot expect people to read or understand unindented code. Please go back and indent the code correctly with spaces not tabs.
I tried running your code, but something went wrong with my use of log; it said it couldn’t find the function, even though I made sure to write #include <math.h>.
Try putting some debugging code in: lots of print statements.
Also divide that main() function; it looks too long to me.
I agree. Here's the link:
subject: Help needed: C Code freezes mid execution
It's not a secret anymore!