Thread: multi array to function

  1. #1
    Unregistered
    Guest

    Unhappy multi array to function

    How do I send multi dimentional arrays to functions and output each line in the array and are there different ways to acheive this i,ve got.

    void output(char *list);

    int main
    {
    char list[7][70];

    /* array filled here */

    output(list);

    }

    void output(char *list)
    {
    int loop;

    for(loop=0;loop<7;loop++)
    printf("%s\n",list[loop]);
    }

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    void output(char [][70]);

    int main
    {
    char list[7][70];

    /* array filled here */

    output(list);

    }

    void output(char list[][70])
    {
    int i;
    for(i=0;i<7;i++)
    printf("%s\n",list[i]);
    }
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Code:
    void output(char *list);
    
    int main
    {
    char list[7][70];
    /* array filled here */
    output(list);
    }
    
    void output(char *list)
    {
    int loop;
    int loop2;
    for(loop=0;loop<7;loop++)
    {
    for(loop2=0; loop2<70; loop2++)
    {
    printf("%c\n",list[loop][loop2]);
    }
    }

    So that's the nested syntax.That prints each char to a separate line.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

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, 04:23 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 10:00 AM