Hey guys I'm new to C and relatively new to programming, but I'm getting an error I've never seen before. All my research on this board and online has to do with something called SDL but I dont know what that is, therefore I dont use it....ha.
Anyways my code is below, its a simple linked list(Which i probably botched) and it reads from a file, adds information, and writes to the file again. I havent done the writing part yet, should be cake though.
Yikes I forgot to post the error. lol.
ERROR:
1>Linking...
1>LINK : fatal error LNK1561: entry point must be defined
Also im looking at the fputs function to write, and im thinking that it isnt right because p is a FILE pointer but its set to read. I think I need to initialize and use q for that.
Also does fputs() let me use "" to add \t for formatted file writing?
Example:
John Williams 99.80 Average.
Code is below:
Code:#include<stdio.h> #include<string.h> #include<stdlib.h> struct Student{ float ave; char name[128]; struct Student* next; }*head = (Student *)malloc(sizeof(Student)); int main() { struct Student* curr =(Student *)malloc(sizeof(Student)); float i = 0.0; int count = 0, x, k; FILE* p = fopen("studentListInFile.txt","r"); FILE* q = fopen("studentListInFile2.txt", "w"); if (curr == 0){ printf("out of memory\n"); return -1;} head->next = NULL; curr=head; curr->next = NULL; while(!feof(p)) { fgets(curr->name, 40, p); curr->ave = 0.0; curr->next = (Student *)malloc(sizeof(Student)); curr = curr->next; curr->next=NULL; count++; } curr = head; for (x = 0; x<count; x++) { printf("Enter the final average for the student: "); scanf("%f", i); curr->ave = i; curr = curr->next; } curr = head; for(k = 0; k< count; k++) { fputs(curr->name, q); fprintf(q, "\t%f\0", curr->ave); curr = curr->next; } curr=head; for(x=0;x<count;x++) { free(curr); curr = curr->next; } free(head); fclose(p); fclose(q); return 0; }


