1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

segmentation fault on fprintf to stderr after modulo

Discussion in 'C' started by edbarker, Aug 28, 2010.

  1. edbarker

    edbarker New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    I have a program which processes thousands of chemical structures. To keep track of how many are being processed, and to avoid staring at a blinking cursor for minutes not knowing if anything is happening, I included a simple bit of code:

    What could possibly go wrong? Well when it reached entry 200999 it bombed out with a segmentation fault. Thinking it could be the structure there I cut it out and repeated it. This time it bombed out on entry 240999. These were suspiciously round numbers so I decided to cut out this bit of code and the program worked fine, albeit with just a blinking cursor. I'm curious to know why this might be. Haven't included any other code as I can't see how it could clash, unless anyone thinks differently. Why would this code cause a seg fault?

Share This Page