Herkese merhaba, ben 3 linked list olusturdum headleri ayrı ayrı tuttum ve baska bir fonsiyona gecirdim ancak degere ulasmak ıstedıgımde adrese ulasıp degeri vermiyor lutfen yardım.. // int sum() kısmında adrese ulasamıyorum
#include<stdlib.h> #include<stdio.h>
typedef struct linkedlist_node { int data; struct linkedlist_node *next; }NODE;
int linklist(NODE *,int); int sum(NODE *,NODE *,NODE *);
int main() { NODE *head1=NULL,*head2=NULL,*head3=NULL,*head4=NULL; int y;
printf("--PLEASE ENTER ELEMENTS OF MATRIX[3][3]--\n"); linklist(head1,1); linklist(head2,2); linklist(head3,3);
sum(head1,head2,head3);
return 0; }
int linklist(NODE *head,int s){
NODE *tail; int value,x;
for(x=1;x<=3;x++){ printf("\nplease enter element of matrix[%d][%d]:",s,x); scanf("%d",&value);
if(head==NULL){ /// ilk düğüm oluşturulmadıysa önce onu oluşturuyoruz. head = (NODE *)malloc(sizeof(NODE)); if(head==NULL) return 0;//hafıza doluysa programı sonlandır
head->data = value; head->next = NULL; tail = head; /// Sadece ilk düğüm için, head = tail } else { NODE *temp = (NODE *)malloc(sizeof(NODE)); /// Eklenecek düğümler için memory allocation if(temp==NULL) return 0;//hafıza doluysa programı sonlandır
int sum(NODE *head1,NODE *head2,NODE *head3){ int eleman1,eleman2,eleman3,x=12;
NODE *curr;
curr=head1; printf("\n DATA :%d",curr->data);
curr=head2; printf("\n DATA :%d",curr->data);
curr=head3; printf("\n DATA :%d",curr->data);
}
#include<stdlib.h> #include<stdio.h>
typedef struct linkedlist_node { int data; struct linkedlist_node *next; }NODE;
int linklist(NODE **,int); int sum(NODE *,NODE *,NODE *);
int main() { NODE *head1=NULL,*head2=NULL,*head3=NULL,*head4=NULL; int y;
printf("--PLEASE ENTER ELEMENTS OF MATRIX[3][3]--\n"); linklist(&head1,1); linklist(&head2,2); linklist(&head3,3);
sum(head1,head2,head3);
return 0; }
int linklist(NODE **head,int s){
NODE *tail; int value,x;
for(x=1;x<=3;x++){ printf("\nplease enter element of matrix[%d][%d]:",s,x); scanf("%d",&value);
if(*head==NULL){ /// ilk düğüm oluşturulmadıysa önce onu oluşturuyoruz. *head = (NODE *)malloc(sizeof(NODE)); if(*head==NULL) return 0;//hafıza doluysa programı sonlandır
(*head)->data = value; (*head)->next = NULL; tail = *head; /// Sadece ilk düğüm için, head = tail } else { NODE *temp = (NODE *)malloc(sizeof(NODE)); /// Eklenecek düğümler için memory allocation if(temp==NULL) return 0;//hafıza doluysa programı sonlandır