Is this valid?

This is a discussion on Is this valid? within the C++ Programming forums, part of the General Programming Boards category; I am working on a code written by someone else. The function I am currently looking at has a segfault ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    457

    Is this valid?

    I am working on a code written by someone else. The function I am currently looking at has a segfault in it somewhere, but that's all I have to go on. I wonder if this line could be the problem

    Code:
     modf( (it*dt-prev_output_time)/tout, &N);
    Seems fine, except that N is declared as a double. Will modf cause a segfault if the second parameter is not an int? Or will it just cast the int into a double and store it that way?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,265
    Quote Originally Posted by KBriggs
    Seems fine, except that N is declared as a double. Will modf cause a segfault if the second parameter is not an int? Or will it just cast the int into a double and store it that way?
    Eh, the second parameter of modf is a pointer to double, so there is no problem there.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    The second argument to modf is supposed to be a double*.

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    457
    Oh, so it is haha. Sorry for the wasted question :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Minimum valid address value
    By BMintern in forum C Programming
    Replies: 6
    Last Post: 04-12-2008, 09:21 AM
  2. recursion error
    By cchallenged in forum C Programming
    Replies: 2
    Last Post: 12-18-2006, 09:15 AM
  3. Is "public" valid in C?
    By Aries in forum C Programming
    Replies: 7
    Last Post: 06-27-2005, 04:57 AM
  4. Are these valid operators
    By Morgan in forum C Programming
    Replies: 3
    Last Post: 08-12-2003, 12:56 PM
  5. Azbia - a simple RPG game code
    By Unregistered in forum Game Programming
    Replies: 11
    Last Post: 05-03-2002, 07:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21