when you declared " h" it contains garbage address . h->a is meaningless . read pointers chapter from K nd R for full details about pointers in C . On Aug 9, 2011 9:11 PM, "programming love" <love.for.programm...@gmail.com> wrote: > #include<stdio.h>typedef struct {char * a; > }*nodeptr; > main(){nodeptr h;h->a="programming";printf("hi %s\n", h->a);} > > @sidharth: thanks a lot for correcting me :) > @aditya : no. there was some mistake; > > in the code i pasted above it's giving segmentation fault. Is it cause i'm > initializing h without using malloc?? > Please throw light on this problem > And in the following code > char *s; > scanf("%s", s); > why isn't it possible to store a string in s?? > > Please explain both concepts. > > -- > You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. >
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.