| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Well I managed to clear all the errors of my last thread but I a link error occurs when I compile.
Im usind C++.Net studentlist error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup studentlist fatal error LNK1120: 1 unresolved externals What is this? How do I fix this problem! |
|
#2
|
||||
|
||||
|
Post the code you're using, we don't have crystal balls that give us the solutions to problems unseen......
![]()
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips. ![]() |
|
#3
|
|||
|
|||
|
Quote:
OOps sorry im new at this. |
|
#4
|
|||
|
|||
|
// This is the testdriver.cpp file
#include <stdio.h> #include <stdlib.h> #include "list.h" void main(){ int num, stuId; List l; l = CreateList(); puts(" \n HELLO WELCOME TO THE PROGRAM MENU \n===================================\n1. Write student.txt into a list."); puts("2. Delete a file from the list.\n3. Search a student id in the list.\n4. Print the entire list.\n"); puts("Enter your selection or quit."); scanf("%d", &num); while(num > 0 && num < 5){ switch(num){ case 1: if(InsertInList(l)) puts("Student.txt file has been read."); break; case 2: puts("Enter the id of the student you would like deleted.\n"); scanf("%d", &stuId); if(DeleteInList(stuId, l)) puts("The student has been deleted.\n"); else puts("That student does not exist.\n"); break; case 3: puts( "Enter the id of the student you are seeking.\n"); scanf("%d", &stuId); stuId = SearchList(stuId, l); if(stuId > 0) printf("The student record is at location %d.\n", stuId); else puts("Sorry the student record is not available."); break; case 4: PrintList(l); break; default: break; } scanf("%d", &num); } puts("\nPROGRAM TERMINATED!\n"); } // list.cpp #include "list.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXSIZE 4 typedef struct data{ int id; int birthyear; char name[20]; }basestruct; typedef struct list_format{ int size; int maxsize; data *dt; }basic_list; List CreateList(){ List temp; temp = (List) malloc(sizeof(basic_list)); temp->size = 0; temp->maxsize = MAXSIZE; temp->dt = (data*) malloc(sizeof(data) * MAXSIZE); return temp; } bool InsertInList(List l){ FILE *stuPtr; data *temp; char *token, info[50]; // info to read in file // for( int i = 0; i < l->size; i++ ) // printf("Id: %d\nName: %s\nBirthyear: %d\n\n", l->dt[i].id, l->dt[i].name, l->dt[i].birthyear); if((stuPtr = fopen("student.txt", "r")) == NULL){ // to open the student.txt file, save it in the solution folder puts( "Sorry unable to open file.\n"); // "Visual Studios Projects" & in the folder with your solutions name return false; } while(!feof(stuPtr)){ // while the pointer not at the end of the file fgets(info, 50, stuPtr); // reads in 50 characters from stuPtr into the info array if(l->size == l->maxsize){ // stack is full(l->size == l->maxsize) l->maxsize++; temp = (data*) malloc(sizeof(data) * l->maxsize); // full so stack has to be created for( int i = 0; i < l->size; i++){ temp[i].birthyear = l->dt[i].birthyear; // transfers data to the temp stack temp[i].id = l->dt[i].id; strcpy(temp[i].name, l->dt[i].name); } // copy string(name) into temp l->dt = temp; } token = strtok(info, "\""); // tokenize the string and copies them into variable l->dt[l->size].id = atoi(token); // that are at the bottom of the stack (location l->size) token = strtok(NULL, "\""); strcpy(l->dt[l->size].name, token); // strcpy used to copy the string name token = strtok(NULL, "\""); l->dt[l->size].birthyear = atoi(token); l->size++; } fclose(stuPtr); // close the pointer to file return true; } bool DeleteInList(int id, List l){ int location = -1; // initialize to false for( int i = 0; i <= l->size; i++){ // checks the location of id if(l->dt[i].id == id) // locate the id location = i; // set location } if(location < 0) // otherwise return false; // return false if not in list for (; location < l->size; location++){ // by moving downward from "location" and shifting each value up an array space, // overwrite the unwanted entry l->dt[location].id = l->dt[location + 1].id; l->dt[location].id = l->dt[location + 1].id; strcpy(l->dt[location].name, l->dt[location + 1].name); } l->size--; // decrement for deleted student return true; // return } int SearchList(int element, List l){ for( int i = 0 ; i <= l->size; i++ ){ // array[0] = location 1 if(l->dt[i].id == element) return (i + 1); // element location in list } return -1; // not in list } void PrintList(List l) { for( int i = 0; i < l->size; i++ ) printf("Id: %d\nName: %s\nBirthyear: %d\n\n", l->dt[i].id, l->dt[i].name, l->dt[i].birthyear); } void DestroyList(List l){ free(l); } // list.h #include "list.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXSIZE 4 typedef struct data{ int id; int birthyear; char name[20]; }basestruct; typedef struct list_format{ int size; int maxsize; data *dt; }basic_list; List CreateList(){ List temp; temp = (List) malloc(sizeof(basic_list)); temp->size = 0; temp->maxsize = MAXSIZE; temp->dt = (data*) malloc(sizeof(data) * MAXSIZE); return temp; } bool InsertInList(List l){ FILE *stuPtr; data *temp; char *token, info[50]; // info to read in file // for( int i = 0; i < l->size; i++ ) // printf("Id: %d\nName: %s\nBirthyear: %d\n\n", l->dt[i].id, l->dt[i].name, l->dt[i].birthyear); if((stuPtr = fopen("student.txt", "r")) == NULL){ // to open the student.txt file, save it in the solution folder puts( "Sorry unable to open file.\n"); // "Visual Studios Projects" & in the folder with your solutions name return false; } while(!feof(stuPtr)){ // while the pointer not at the end of the file fgets(info, 50, stuPtr); // reads in 50 characters from stuPtr into the info array if(l->size == l->maxsize){ // stack is full(l->size == l->maxsize) l->maxsize++; temp = (data*) malloc(sizeof(data) * l->maxsize); // full so stack has to be created for( int i = 0; i < l->size; i++){ temp[i].birthyear = l->dt[i].birthyear; // transfers data to the temp stack temp[i].id = l->dt[i].id; strcpy(temp[i].name, l->dt[i].name); } // copy string(name) into temp l->dt = temp; } token = strtok(info, "\""); // tokenize the string and copies them into variable l->dt[l->size].id = atoi(token); // that are at the bottom of the stack (location l->size) token = strtok(NULL, "\""); strcpy(l->dt[l->size].name, token); // strcpy used to copy the string name token = strtok(NULL, "\""); l->dt[l->size].birthyear = atoi(token); l->size++; } fclose(stuPtr); // close the pointer to file return true; } bool DeleteInList(int id, List l){ int location = -1; // initialize to false for( int i = 0; i <= l->size; i++){ // checks the location of id if(l->dt[i].id == id) // locate the id location = i; // set location } if(location < 0) // otherwise return false; // return false if not in list for (; location < l->size; location++){ // by moving downward from "location" and shifting each value up an array space, // overwrite the unwanted entry l->dt[location].id = l->dt[location + 1].id; l->dt[location].id = l->dt[location + 1].id; strcpy(l->dt[location].name, l->dt[location + 1].name); } l->size--; // decrement for deleted student return true; // return } int SearchList(int element, List l){ for( int i = 0 ; i <= l->size; i++ ){ // array[0] = location 1 if(l->dt[i].id == element) return (i + 1); // element location in list } return -1; // not in list } void PrintList(List l) { for( int i = 0; i < l->size; i++ ) printf("Id: %d\nName: %s\nBirthyear: %d\n\n", l->dt[i].id, l->dt[i].name, l->dt[i].birthyear); } void DestroyList(List l){ free(l); } ![]() Last edited by unclebuck : November 9th, 2005 at 07:29 PM. Reason: I posted the solution to my program if anyone is interested |
|
#5
|
|||
|
|||
|
Regarding the error you're getting it looks like you have set the project settings to an Windows application. But you're program is a commandline application....
Start a new project and select Commandline application. You can also select that a cpp file is generated ("Hello World"). Continue from this part by pasting your code. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > I get a link error when compile C++.Net |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|