hey,
I am somewhat a new programmer, so my code isn't the best, but I need to turn this into linked list. Can anyone help?
Code:#include <stdio.h> #include <string.h> typedef struct army { char section_name[81]; char sub_name[81]; int points; char discription[500]; }; int i=0; struct army Army; char file_end[81]; char temp_word[81]; char temp_close[8]="</name>"; char temp_close2[10]="</descrip>"; void main() { char name[81]="<name>", scan[81], descrip[10]="<descrip>"; FILE *inputfile; inputfile = fopen("Rune2.txt","r"); if (inputfile == NULL) { printf("error opening file"); } else { printf("File opened successfully. Loading data...\n\n"); } fscanf(inputfile,"%s", scan); for (fscanf(inputfile," %s ", temp_word); temp_word!=NULL; fscanf(inputfile," %s ", temp_word)) { if (strcmp(temp_word, temp_close)==0) break; strcat(temp_word, " "); strcat(Army.sub_name, temp_word); } fscanf(inputfile,"%d", &Army.points); fscanf(inputfile,"%s", scan); for (fscanf(inputfile," %s ", temp_word); temp_word!=NULL; fscanf(inputfile," %s ", temp_word)) { i++; if (strcmp(temp_word, temp_close2)==0) break; strcat(temp_word, " "); strcat(Army.discription, temp_word); if (i==9) { i=0; strcat(Army.discription, "\n"); } } printf("%s\n%d\n%s\n", Army.sub_name, Army.points, Army.discription); }



LinkBack URL
About LinkBacks



