Sending an Array to a function

This is a discussion on Sending an Array to a function within the C Programming forums, part of the General Programming Boards category; I'm stuck on a problem for my C programming class. I keep trying and trying, but I cannot get my ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    2

    Sending an Array to a function

    I'm stuck on a problem for my C programming class. I keep trying and trying, but I cannot get my program to send an array to a function. I have no idea where to start and my book is not being any help at all (A first book of ANSI C by Gary J. Bronson). I've read the chapter we're supposed to be on through a few times and there's nothing on sending the array to and from a function.

    I suppose I should also mention that my array is supposed to be user entered. I've gotten that to work, but sending it...that's a whole 'notha story =^/.

    If anyone can offer any advice, I'd appreciate it. Thanks in advance.

  2. #2
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    if it's an single array (not a multidimensional), send it like this:
    Code:
    void myFunc1 (int arr[]);
    or
    void myFunc1 (int *arr);
    Also, you can pass the size of the array too, to be sure you're not accessing prohibited memmory.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2
    Ok, thank you very much. Now I've gotten the the array to send to my function *I think* and I'm going to try and print it out to see it was sent. I got an error earlier, but I'm going to try and figure it out before I ask for more help. Once again, thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 05:23 AM
  2. Replies: 4
    Last Post: 11-23-2003, 07:15 AM
  3. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM
  4. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 11:00 AM
  5. Replies: 3
    Last Post: 03-23-2002, 04:20 PM

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