On May 5, 8:32 pm, Christian Hackl <ha...@[EMAIL PROTECTED] > wrote: > Rahul wrote: > > void dfs(struct node * root) > > { > > if(root == NULL) return; > > std::stack <struct node *> s; > > You don't need the struct keyword here. > > > s.push(root); > > > while(!s.empty()) > > { > > struct node * temp = s.pop(); > > That's not how std::stack works. top() and pop() are separate functions:http://www.cppreference.com/cppstack/index.html > > > printf("%d ",temp->data); > > s.push(temp->rptr); > > s.push(temp->lptr); > > } > > } > > > and i get a error saying, > > > ro.c: In function `void dfs(node*)': > > ro.c:419: `stack' undeclared in namespace `std' > > > Am i missing something? > > #include <stack> ? > > -- > Christian Hackl Yes, i missed out to include the stack file... Thanks :-)