Thread: Help with 2d Int Arrays

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    3

    Help with 2d Int Arrays

    Need some help guys; just started working with C and I'm having some issues with arrays. I'm working on making a program to solve the 8-queens problem. I have a function that has a 2d int array passed to it that it uses to calculate elimination values. I want to store these elimination values in another 2d array to be used later. I can't declare an array as a return type like I could in java. So, how would I go about exporting this array?

    Could I pass another parameter, like a pointer to another array outside the function? I don't know much about pointers at all (our professor has just started on the subject).

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by Voondebah View Post
    Need some help guys; just started working with C and I'm having some issues with arrays. I'm working on making a program to solve the 8-queens problem. I have a function that has a 2d int array passed to it that it uses to calculate elimination values. I want to store these elimination values in another 2d array to be used later. I can't declare an array as a return type like I could in java. So, how would I go about exporting this array?

    Could I pass another parameter, like a pointer to another array outside the function? I don't know much about pointers at all (our professor has just started on the subject).
    you can pass the second array as a parameter the same way you pass the first array
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    3
    Wow, I feel silly now. I think I've been just working on the problem too long and overlooked that possibility. Thanks so much, I feel rejuvenated!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  2. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. Converted from Dev-C++ 4 to Dev-C++ 5
    By Wraithan in forum C++ Programming
    Replies: 8
    Last Post: 12-03-2005, 07:45 AM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM