Yardımınıza çok ihtiyacım var bu kodun main kısmı niye çalışmıyor bi bakar mısınız saatlerdir uğraşıyorum. Bi de MAX_ROW değeri dışardan girilecek onu da yapamadım şimdiden teşekkürler #include<stdio.h> #include<string.h> #include<stdlib.h> #include <iostream> #include<cstdio> #define NAME_LENGTH 20 #define MAX_ROW 4
for (int i = 0; i<MAX_ROW; i++){ table.rows.index = -1; sprintf(table.rows.name, "%s", " "); table.rows.pNext = NULL; } } void collision(Row *row, Row *startRow) { _ROW *old; old = startRow; while (startRow){ // Bağlı listenin sonu bulunuyor old = startRow; startRow = startRow->pNext; } old->pNext = row; // Son elemana ilgili kayıt ekleniyor row->pNext = NULL; // bağlı listeninsonubelirleniyor } int RSHash(char *str, int l) { int b = 378551; int a = 63689; int hash = 0; int i = 0; for (i = 0; i < l; str++, i++) { hash = hash * a + (*str); a = a * b; } return (hash & 2147483647) % MAX_ROW; } void add_Row(char *str){ int hash_index; Row *row; hash_index = RSHash(str, strlen(str)); //Hasing fonksiyonu ile benzersiz bir değer üretiyoruz if (table.rows[hash_index].index == -1 || (strcmp(table.rows[hash_index].name, str) == 0)) { //kayıt ekle varsa güncelle table.rows[hash_index].index = hash_index; sprintf(table.rows[hash_index].name, "%s", str); return; } row = (Row *)malloc(sizeof(Row)); //Aksi durumda bir kayıt oluştur if (!row) { puts("yeterli bellek yok!"); exit(0); } row->index = hash_index; sprintf(row->name, "%s", str); collision(row, &table.rows[hash_index]); //ve çakışma listesine ekle } int find_row(char *str) { int hash_index; Row *row;
hash_index = RSHash(str, strlen(str)); // benzersiz değer hashing fonksiyonu ile yeniden hesaplanır if (!strcmp(table.rows[hash_index].name, str))//belirtilen indise bakılır return table.rows[hash_index].index; //veriler aynı ise indis ile geri dönülür else { row = table.rows[hash_index].pNext; while (row) //bağlı liste varsa kayıtlar takip kontrol edilir { if (!strcmp(table.rows[hash_index].name, str)) return table.rows[hash_index].index; // Eğer aranan kayıt bağlı listede ise row = row->pNext; // diğer kayda gecilir } } return -1; //bulunamadı ise -1 ile fonksiyon sonlandırılır } void display_Table(){ int i; Row *row; for (i = 0; i < MAX_ROW; i++){ if (table.rows.index != -1){ printf("%s\n", table.rows.name); row = table.rows.pNext; while (row){ printf("%s\n", row->name); row = row->pNext; } } } } int main(){ int index, num,a; char * name [MAX_ROW]; char secim; int i=0; initialize_Table(); for (;;){ printf(" ekleme (e) \n arama(a) \n listele(l)\n secim: "); scanf("%s", &secim); switch (secim){ case 'e':