Subj : Re: query To : comp.programming From : Joe Wright Date : Thu Sep 22 2005 10:58 pm 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: > > 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"> ); > > }//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? > > 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"}; > > wishes, > AD. > #include #include void func(char **ppc) { char *cp; int i = 0; while ((cp = ppc[i++]) != NULL) { printf("%3d %s\n", (int)strlen(cp), cp); } } int main(void) { char *a[] = {"God", "Father", "Son", "Holy Ghost", NULL}; func(a); return 0; } My apologies to comp.programming. This more properly belongs in comp.lang.c. -- Joe Wright "Everything should be made as simple as possible, but not simpler." --- Albert Einstein --- .