really the N dimensions are not exist to C++, the compiler follow some rules, but, always the data is stored like a unitary array. The compiler use some operations to 'convert' the N dimensions into the real position in the memory array...
2010/1/9 shamir shakir <[email protected]> > > > Hello frieds, > Im new to this group and C/C++ too! I'm stuck with this > code and can't understand how a three dimensional arrray > is used as 2D aray. > Let's have a look, > > * // This translate ENglish to German * > > *#include <stdio.h>* > *#include <string.h>* > > * char words[][2][40] = {* > * "dog", "hund",* > * "no", "nein",* > * "year", "jahr",* > * "child", "kind",* > * "i", "ich",* > * "drive", "fahren",* > * "house", "haus",* > * "to", "zu",* > * "", ""* > * };* > * * > *int main()* > *{* > * char english[80] ;* > * int i ;* > > * printf("Enter English word: ");* > * gets(english) ;* > > * i = 0 ;* > * while( strcmp(words[i][0], "") ){* > * if (!strcmp(english, words[i][0]) ) { // How a three dimensional > array is used as 2D here & if i = 0 initially and i cant understand this > line totally > ** printf("German translation : %s ", words[i][1] ); * > * break ;* > * }* > * i++ ;* > * }* > * * > * if(!strcmp(words[i][0], "") )* > * printf("Not in dictionary\n") ;* > > * return 0 ;* > *}* > > Anyone help this kid? > > thanx > -- > ShishiR > http://DewsWorld.741.com > > > ///////////////////////////////////////////////////////////////////////////////// > ///////////////////////////সকল সৃষ্টি সুখী হোক///////////////////////////// > > ///////////////////////////////////////////////////////////////////////////////// > > [Non-text portions of this message have been removed] > > > -- -------------------------------------------------------- VISIT MY BLOG : http://ageo.blogspot.com/ picture blog : http://ageo.deviantart.com/journal/ [Non-text portions of this message have been removed]
