whats wrong with this?

This is a discussion on whats wrong with this? within the C Programming forums, part of the General Programming Boards category; whats wrong with this? Code: void function(char *stuff[]) { for(int i = 0; i < NUMBER; i++) printf("%s\n", stuff[i]); }...

  1. #1
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195

    whats wrong with this?

    whats wrong with this?

    Code:
    void function(char *stuff[])
    {
        for(int i = 0; i < NUMBER; i++)
            printf("%s\n", stuff[i]);
    }

  2. #2
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195
    The same loop output fine in my main function, so I think I must be doing something wrong with the string pointer.

    I am getting a segmentation fault every time I use stuff[] any where in that function???

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    It works fine for me, perhaps you could post more code such as where you declare and fill the array of pointers and where you call the function.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 04:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 01:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 02:04 PM

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