fork(4) download
  1. #include <iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. struct Node{
  5. int val;
  6. Node* next;
  7. };
  8. void addBeg(Node* head,int val)
  9. {
  10. Node* temp = (Node*)malloc(sizeof(Node));
  11. temp->val=val;
  12. temp->next=head;
  13. head=temp;
  14. //////////////////////////////
  15. cout << "&Head: " << &head << endl;
  16. cout << "Head: " << head << endl;
  17. cout << "Head->val: " << head->val << endl;
  18. cout << "Head->next: " << head->next << endl;
  19. cout << "--------------" << endl;
  20. cout << "&Temp: " << &temp << endl;
  21. cout << "Temp: " << temp << endl;
  22. cout << "Temp->val: " << temp->val << endl;
  23. cout << "Temp->next: " << temp->next << endl;
  24. cout << "--------------" << endl;
  25. /////////////////////////////
  26. }
  27. int main()
  28. {
  29. Node* head=0;
  30. std::cout << "------ Wstawianie na poczatek ----------------" << std::endl;
  31. addBeg(head,1);
  32. cout << "&Head: " << &head << endl;
  33. cout << "Head: " << head << endl;
  34. cout << "Head->val: " << head->val << endl;
  35. cout << "Head->next: " << head->next << endl;
  36. cout << head->val << endl;
  37. //addBeg(head,2);
  38. return 0;
  39. }
Runtime error #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
------ Wstawianie na poczatek  ----------------
&Head: 0xbf8838d0
Head: 0x91f3008
Head->val: 1
Head->next: 0
--------------
&Temp: 0xbf8838bc
Temp: 0x91f3008
Temp->val: 1
Temp->next: 0
--------------
&Head: 0xbf8838ec
Head: 0