|
-
September 17th, 2010, 05:45 AM
#1
question about two dimensional arrays
Hi to all,
Hope you all will be fine.I am confused about Arrays . Consider this, it's a single dimensional integer array
Code:
int product_codes[3] = {10, 972, 45};
Also character array
Code:
char name[] = {'S', 'a', 'm', '\0'};
See, For initialize single dimensional array we use one set of curly({ }) braces and separate each character with comma(,).
But what about this
Code:
char Ones[10][10] = {"One", "Two","Three","Four","Five","Six","Seven","Eight","Nine"};
See, in this we also use singe set of curly braces and separate each character with comma(,), but it's not a single dimension, it's a two dimensional array. How and why?
If we declare it like this i get an error
Code:
char Ones[10] = {"One", "Two","Three","Four","Five","Six","Seven","Eight","Nine"}; //Error
Can someone please explain to me why we declare it with two dimension and why i getting error while creating it with single dimension.
It's a two dimension array
Code:
int matrix[2][4] ={ {1, 2, 3, 4}, {10, 20, 30, 40} };
We used two set of curly braces inside a single set of curly braces to initialize two dimensional array but we didn't initialize {"One", "Two",....} array in this manner why?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|