Hi Deepak, "Deepak Kotian" <[EMAIL PROTECTED]> writes:
> Hi, > > Please check the code segment. > /*************code start ****/ > #include <stdio.h> > int func1(char **a_argv){ > while (*a_argv!=3DNULL) > printf("\n%s", *a_argv++); > return(0); > } > > int main(int argc, char *argv[]){ > func1(&argv[0]); > } > /*************code end ****/ > > This func1 function prints all the arguments with no problem, because = > main() is probably always=20 > on stack, so it works probably. > Do anyone see any problem, if one passes argv[] this way ? Will there be = > portability issues, like=20 > on other UNIX flavors,etc. Why not just do: #include <stdio.h> int func1(char **argv) { while(**argv != NULL) { printf("%s\n", *(argv++)); } } int main(int argc, char **argv) { func1(argv); } You are passing the pointer-pointer by value, but that's fine. The only thing that is troubling is the (**argv != NULL) which assumes that the last string is a NULL string (the first character is NULL), as opposed to using the count (argc), which may not be the case (it's not here). But this is certainly fine and standard C. Here's how I would do it: #include <stdio.h> int func1(int argc, char **argv) { int i; for(i = 1; i < argc; i++) { printf("%s\n", *(argv + i)); } } int main(int argc, char **argv) { func1(argc, argv); } Elizabeth -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]