Subj : Re: query To : comp.programming From : Thad Smith Date : Thu Sep 22 2005 09:13 am deshpandeajit@yahoo.com wrote: > Hi, > I have following piece of C-code below. Pls go thru and try to answer > the questions I have below: These kind of questions are about language usage, so should be asked in comp.lang.c or comp.lang.c.moderated. This forum is for language-independent programming issues, such as algorithms. I am assuming you have #include > void func(char **); > main() > { > char *a[]={"god","father"};//ARRAY OF strings,i.e. > > func(a); > > } > > void func(char **ptr) > { > Now here in function "func" i want to access(printf), the 2 strings > "god" and "father". How can I do so. > e.g. printf("%s %s ",*ptr,*ptr +/- first pointer value for the first string "god"> ); printf("%s %s ",ptr[0], ptr[1]); > > }//func ends > > 1.)My question is how can I access/printf the second string "father" by > using variable ptr. How do I calculate the pointer offsets for this > second string from the first one? Using a subscript of 1 accesses the second pointer to char in the array, etc. > 2.)Second question : Is there any way by which I can get sizeof the two > strings in bytes, for the definition below - > char *a[]={"god","father"}; You can use strlen() to get the number of characters in the string preceding the terminating null. It will yield 3 and 6, respectively, for your example strings. You need to include header . Thad .