Δημοσιεύτηκε: 05 Δεκ 2010, 19:49
Καλησπερα! Στο παρακατω προγραμμα μου βγαζει Segmentation fault μολις αρχισω να το τρεχω. Αν μπορει καποιος να βοηθησει εγκαιρα θα ημουν ευγνωμον!!! Ευχαριστω!
- Κώδικας: Επιλογή όλων
# include <stdio.h>
# include <string.h>
# include <ctype.h>
# define NUMWORDS 100
# define WORDSIZE 15
typedef struct {
char lhmma[WORDSIZE];
int apostash;
}bookT;
void ekxwrhsh(bookT kataxwrhseis[]){
int i, k;
char test_str[WORDSIZE];
/*char format_str[WORDSIZE];*/
i = 0;
k = 0;
do{
scanf("%s", test_str);
if (strcmp(test_str, "XXX") == 0){
k = 1;
}
else{
if(test_str != NULL){
strcpy(kataxwrhseis[i].lhmma, test_str);
}
else{
printf("error.....\n");
}
}
i++;
}while(k == 0 || i <= NUMWORDS);
}
int main (int argc, char *argv[]){
bookT kataxwrhseis[NUMWORDS];
int i;
ekxwrhsh(kataxwrhseis);
for(i=0; i<= 100; i++){
printf("%s\n", kataxwrhseis[i].lhmma);
}
return (0);
}