Thread: Segmentation fault. passing extra parameters to function

  1. #1
    Registered User
    Join Date
    Mar 2004

    Segmentation fault. passing extra parameters to function

    I have a function declared like so:

    PHP Code:
    int funcint file_numint aint lint g ); 

    I decided to change this so it could accept another parameter:

    PHP Code:
    int funcint file_numint aint lint g int o); 
    and call the function like so:

    PHP Code:
    However now, with that extra parameter, i get a segmentation fault.

    There is a strcpy in this function, where i copy file/dir names to an array. That array gets passed to qsort, and then onwards to another function to be printed.

    The array is declared like so:

    PHP Code:
    char Array[file_num][100]; /* probably not the best way, but il leae it for the moment */ 
    when i take the strcpy function out, i dont get a core dump.

    Are there common problems when passing more parameters to functions like im trying to do?

    Last edited by jamie85; 10-29-2005 at 05:17 PM.

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Well, not unless you have almost no memory available.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    ... kermit's Avatar
    Join Date
    Jan 2003
    What does your function definition look like?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. Replies: 7
    Last Post: 04-19-2006, 11:17 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM