Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > Re: order of ar...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 10 Topic 4079 of 4262
Post > Topic >>

Re: order of array subscripts

by Keith Thompson <kst-u@[EMAIL PROTECTED] > Mar 26, 2008 at 12:43 AM

"Jim Langston" <tazmaster@[EMAIL PROTECTED]
> writes:
[...]
> Maybe this code will help explain things a little.
>
> #include <iostream>
>
> int main()
> {
>     char Data[3][7] = {"Line 1", "Line 2", "Line 3" };
>
>     std::cout << Data[0] << "\n";
>     std::cout << Data[1] << "\n";
>     std::cout << Data[2] << "\n";
>
>     std::cout << Data[0][0] << " " << Data[0][1] << "\n";
> }
>
> The output being:
> Line 1
> Line 2
> Line 3
> L i
>
> It is an array of 3 arrays of char.   Seeing it in this format should
make 
> it fairly clear what is going on.

This thread is cross-posted to comp.lang.c and alt.comp.lang.learn.c-c++.
A C++ example is appropriate in the latter, but not in the former.

Here's the C equivalent:

#include <stdio.h>

int main(void)
{
    char Data[3][7] = {"Line 1", "Line 2", "Line 3" };

    printf("%s\n", Data[0]);
    printf("%s\n", Data[1]);
    printf("%s\n", Data[2]);

    printf("%c %c\n", Data[0][0], Data[0][1]);

    return 0;
}

-- 
Keith Thompson (The_Other_Keith) <kst-u@[EMAIL PROTECTED]
>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
 




 10 Posts in Topic:
order of array subscripts
noway@[EMAIL PROTECTED]   2008-03-25 07:45:00 
Re: order of array subscripts
"Alf P. Steinbach&qu  2008-03-25 09:06:37 
Re: order of array subscripts
Keith Thompson <kst-u@  2008-03-25 09:00:23 
Re: order of array subscripts
vippstar@[EMAIL PROTECTED  2008-03-25 11:49:21 
Re: order of array subscripts
Andrey Tarasevich <and  2008-03-25 12:03:26 
Re: order of array subscripts
Eric Sosman <Eric.Sosm  2008-03-25 15:55:08 
Re: order of array subscripts
"Jim Langston"   2008-03-25 23:59:28 
Re: order of array subscripts
Keith Thompson <kst-u@  2008-03-26 00:43:57 
Re: order of array subscripts
Flash Gordon <spam@[EM  2008-03-26 07:38:23 
Re: order of array subscripts
pete <pfiland@[EMAIL P  2008-03-29 00:10:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 13:28:34 CDT 2008.