Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct node{
- int val;
- node* next;
- };
- void add(node* test, int a ){
- node* temp = new node;
- temp->val =a;
- temp->next = NULL;
- if(test==NULL){
- test=temp;
- }else{
- node* t = test;
- while(t->next!=NULL){
- t=t->next;
- }
- t->next = temp;
- }
- }
- int main(){
- node* a;
- a = NULL;
- add(a, 10);
- cout<<a->val;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement