Segmentation fault. passing extra parameters to function

This is a discussion on Segmentation fault. passing extra parameters to function within the C Programming forums, part of the General Programming Boards category; I have a function declared like so: PHP Code: int func (  int file_num ,  int a ,  int l ,  int g  );  I ...

  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 06: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, 02:22 PM
  2. Replies: 28
    Last Post: 07-17-2006, 12:35 AM
  3. Replies: 7
    Last Post: 04-19-2006, 12:17 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM

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