vendredi 13 mars 2015

code explanation c++ [struct / two diamentinal array / pointers]


I'm new to c++ and its developing.i have two methods void accumulation(void) & void chartest( char * nam) accumulation is called in my main.cpp file.



void accumulation(void)
{
char * test[] ={"Rehan ","Kalpana"};
chartest(&test[0][1]);
}

void chartest( char * nam)
{
printf("char name -> %s \n",nam);
}


i changed the values in chartist as follows then i got output as follows



chartist(&test[0][1] - char name -> ehan
chartest(&test[1][1])-char name -> alpana
chartest(&test[1][0]) -char name -> Kalpana
chartest(&test[0][0])- char name -> Rehan


can anyone please explain why this happens. it will help me a lot. thank you




Aucun commentaire:

Enregistrer un commentaire