Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- typedef
- struct node{
- int data;
- struct node *next;
- }
- int_list;
- int_list *create_list(){
- return NULL;
- }
- int pushback(int_list **head,int d){
- int_list *newNode = (int_list*)malloc(sizeof(int_list));
- newNode->data = d;
- newNode->next = NULL;
- if(*head== NULL){
- *head = newNode;
- }
- else
- {
- int_list *current = *head;
- while (current->next != NULL) {
- current = current->next;
- }
- current->next = newNode;
- }
- return 0;
- }
- void print_list(int_list *list)
- {
- if (list==NULL);
- else {
- printf("%d ", list->data);
- print_list(list->next);
- }
- }
- int main (int argc, char *argv[]){
- int_list *lista = create_list();
- if (argc == 4){
- int a = atoi(argv[1]);
- int b = atoi(argv[2]);
- int c = atoi(argv[3]) ;
- pushback(&lista, a);
- pushback(&lista, b);
- pushback(&lista, c);
- print_list(lista);
- printf("\n");
- }
- else {
- printf("neeeeej");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement