Find the below program,
why this is giving Segmentation fault while printing *ppcch? and why not in *argv? as both are pointer to pointer to char they should behave in same way.Code:#include <stdio.h> int main(int argc, char** argv) { char** ppch = "Hello World"; printf( "%s\n", *argv ); printf( "%s\n", *ppch ); // Segmentation fault return 0; }
but if I try to print the value value of ppch using
It is working fine but if I try this same thing withCode:printf( "%s\n", ppch )
It will print some junk values.Code:printf( "%s\n", *argv );
can any one give me the logical reason why this is happening?
--
Regards
Kunal



1Likes
LinkBack URL
About LinkBacks


