C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 14th, 2005, 10:36 PM
unclebuck unclebuck is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 6 unclebuck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 59 sec
Reputation Power: 0
Talking I get a link error when compile C++.Net

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!

Reply With Quote
  #2  
Old October 15th, 2005, 06:40 PM
B-Con's Avatar
B-Con B-Con is offline
:bcon: moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: int main()
Posts: 351 B-Con User rank is Private First Class (20 - 50 Reputation Level)B-Con User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 23 h 1 m 43 sec
Reputation Power: 4
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.



Reply With Quote
  #3  
Old October 23rd, 2005, 11:17 PM
unclebuck unclebuck is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 6 unclebuck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 59 sec
Reputation Power: 0
Quote:
Originally Posted by B-Con
Post the code you're using, we don't have crystal balls that give us the solutions to problems unseen......


OOps sorry im new at this.

Reply With Quote
  #4  
Old October 23rd, 2005, 11:22 PM
unclebuck unclebuck is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 6 unclebuck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 59 sec
Reputation Power: 0
Thumbs up Thank for everyones input-this is the completed program.

// 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

Reply With Quote
  #5  
Old October 24th, 2005, 05:48 AM
MichaelSoft MichaelSoft is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Location: The Netherlands
Posts: 121 MichaelSoft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 20 sec
Reputation Power: 4
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > I get a link error when compile C++.Net


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway