Jump to content
  • Advertisement
Sign in to follow this  
tscott203

C++ help.....

This topic is 2952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For all the good Google dose you would think i could find a decent answer to my problem...

here is the error i can't(thus far) get rid of...

1>Test1Part2.obj : error LNK2019: unresolved external symbol "void __cdecl inputs(int,int,int * const,int,char * const,char * const,char * const,char * const)" (?inputs@@YAXHHQAHHQAD111@Z) referenced in function _main
1>F:\C++\**\Debug\Test1part2.exe : fatal error LNK1120: 1 unresolved externals

i did however manage to chase it down to what line it is on, cant for the life of me figure out what is missing...
{header files I'm using}
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
using namespace std;

inputs(num, numb, Pcent, pcent, name1, name2, name3, name4);// error is here in this line!!!!!!
calu(input, num, Pcent, pcent, numb, innumb);
disp(Pcent, pcent, input, num, numb, name1, name2, name3, name4);
system("pause");
}

when i comment it out the error goes away, though the program doesn't work.(>.<)

if need more of the code let me know...

Share this post


Link to post
Share on other sites
Advertisement
phresnel:
yes i have used all the input library's i know, including stdio

however its not an input, that is just what i named it...


Andy474:
not sure what you mean....
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <stdio>
using namespace std;

int inputs(const int num, const int numb, int Pcent[], const int pcent, char name1[], char name2[], char name3[], char name4[]);
void calu(int Pcent[], const int pcent, int input[], const int num, const int numb, int innumb);
void disp(int Pcent[], const int pcent, int input[], const int num, const int numb,char name1[], char name2[], char name3[], char name4[]);

int main(){

const int num = 5;
int input[num] = {};
const int numb = -1;
//input array
char name1[]= "Riley";
char name2[]= "Fuller";
char name3[]= "Nagle";
char name4[]= "Boyd";
//asigns each name to a char array, allowing easy change
const int pcent= 5;
int Pcent[pcent]={};
//percentage arrays
int innumb=0;

innumb = inputs(num, numb, Pcent, pcent, name1, name2, name3, name4);// error is here in this line!!!!!!
calu(input, num, Pcent, pcent, numb, innumb);
disp(Pcent, pcent, input, num, numb, name1, name2, name3, name4);
system("pause");
}

is the main part of the program, the rest is just functions.
its the int main() calling function....

Share this post


Link to post
Share on other sites

I take it inputs is a function you wrote. By the looks of it, you tell the compiler to expect a function called inputs, but you never give it a body. At the end of your code, do:

int inputs(const int num, const int numb, int Pcent[], const int pcent, char name1[], char name2[], char name3[], char name4[])
{
//All your code goes here that inputs should do
}



Note: It's <cstdio>, rather than <stdio>, and you can use [ source ] [ /source ] tags to format code on here. :)

Share this post


Link to post
Share on other sites
The Communist Duck;

laughs, your right it is #include <cstdio>
however it didn't help any
and it dose, though i should just put the hole code.....
 
#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;cstdlib&gt;
#include &lt;cstring&gt;
#include &lt;cstdio&gt;
using namespace std;

int inputs(const int num, const int numb, int Pcent[], const int pcent, char name1[], char name2[], char name3[], char name4[]);
void calu(int Pcent[], const int pcent, int input[], const int num, const int numb, int innumb);
void disp(int Pcent[], const int pcent, int input[], const int num, const int numb,char name1[], char name2[], char name3[], char name4[]);

int main(){

const int num = 5;
int input[num] = {};
const int numb = -1;
//input array
char name1[]= "Riley";
char name2[]= "Fuller";
char name3[]= "Nagle";
char name4[]= "Boyd";
//asigns each name to a char array, allowing easy change
const int pcent= 5;
int Pcent[pcent]={};
//percentage arrays
int innumb=0;

innumb = inputs(num, numb, Pcent, pcent, name1, name2, name3, name4);// error is here in this line!!!!!!
calu(input, num, Pcent, pcent, numb, innumb);
disp(Pcent, pcent, input, num, numb, name1, name2, name3, name4);
system("pause");
}


int inputs(const int num, const int numb, char name1[], char name2[], char name3[], char name4[]){
int innumb;

cout&lt;&lt;"Please enter the number associated with the candidate's name for each vote."&lt;&lt;endl;
cout&lt;&lt;"1: "&lt;&lt;name1&lt;&lt;endl;
cout&lt;&lt;"2: "&lt;&lt;name2&lt;&lt;endl;
cout&lt;&lt;"3: "&lt;&lt;name3&lt;&lt;endl;
cout&lt;&lt;"4: "&lt;&lt;name4&lt;&lt;endl;
//prints the name of the candidate's

for(int i=1; i&lt;num; i++){//used as input and verification
do{
cout &lt;&lt;"Enter Vote(1-4): ";
cin&gt;&gt;innumb;
if(innumb == 0){
cout&lt;&lt;"Invalid value. Enter 1, 2, 3 or 4. Please try again."&lt;&lt;endl;}
if((innumb &lt; -1)||(innumb &gt;= 5)){
cout&lt;&lt;"Invalid value. Enter 1, 2, 3 or 4. Please try again."&lt;&lt;endl;}}
while ((innumb != 0)&&(innumb &lt; 5)&&(innumb == numb));}
//gets the inputs for each voter, ends with -1
return innumb;
}

void calu(int Pcent[], const int pcent, int input[], const int num, const int numb, int innumb){
int r = 1;

for(int h = 1; h &lt; num; h++){
for(int y =1 ; y &lt; pcent; y++){
do{
if(innumb == 1){//canditate 1
input[1]++;//For Total number of votes for canditate 1
Pcent[1]++;}//For Precentage of votes
}while(r == 1);}}

for(int j = 1; j &lt; num; j++){
for(int u = 1; u &lt; pcent; u++){
do{
if(innumb == 2){//canditate 2
input[2]++;//For Potal number of votes for canditate 2
Pcent[2]++;}//For Precentage of votes
}while(r == 1);}}

for(int k = 1;k &lt; num; k++){
for(int n = 0; n &lt; pcent; n++){
do{
if(innumb == 3){//canditate 3
input[3]++;//For Total number of votes for canditate 3
Pcent[3]++;}//For Precentage of votes
}while(r==1);}}

for(int l = 0; l &lt; num; l++){
for(int m = 0; m &lt; pcent; m++){
do{
if(innumb == 4){//canditate 4
input[4]++;//For Total number of votes for canditate 4
Pcent[4]++;}//For Precentage of votes
}while(r==1);}}

if(innumb == numb){//exits when user inters -1
r = 0;}

}

void disp(int Pcent[], const int pcent, int input[], const int num, const int numb, char name1[], char name2[], char name3[], char name4[]){
cout&lt;&lt;"candidate "&lt;&lt;" votes"&lt;&lt;" percentage"&lt;&lt;endl;//final disply title
int precentage,precent1,precent2,precent3,precent4;

precentage = Pcent[1+2+3+4];
//Total votes for each candetate / number of votes for each canditate
precent1 = input[1]/Pcent[precentage];
precent2 = input[2]/Pcent[precentage];
precent3 = input[3]/Pcent[precentage];
precent4 = input[4]/Pcent[precentage];

cout&lt;&lt;" "&lt;&lt;name1 &lt;&lt;" "&lt;&lt;input[1] &lt;&lt;" %"&lt;&lt;fixed&lt;&lt;setprecision(2)&lt;&lt;precent1&lt;&lt;endl;
cout&lt;&lt;" "&lt;&lt;name2 &lt;&lt;" "&lt;&lt;input[2] &lt;&lt;" %"&lt;&lt;fixed&lt;&lt;setprecision(2)&lt;&lt;precent2&lt;&lt;endl;
cout&lt;&lt;" "&lt;&lt;name3 &lt;&lt;" "&lt;&lt;input[3] &lt;&lt;" %"&lt;&lt;fixed&lt;&lt;setprecision(2)&lt;&lt;precent3&lt;&lt;endl;
cout&lt;&lt;" "&lt;&lt;name4 &lt;&lt;" "&lt;&lt;input[4] &lt;&lt;" %"&lt;&lt;fixed&lt;&lt;setprecision(2)&lt;&lt;precent4&lt;&lt;endl;
//Final output to display name, votes and percentage for each candidate.
}

Share this post


Link to post
Share on other sites
Quote:

phresnel:
yes i have used all the input library's i know, including stdio

however its not an input, that is just what i named it...


I didn't say you have to #include iostreams or the C++ standard library, but rather that you must

Quote:
link the library or include the source file that defines inputs().


i.e. look where your inputs(...) is defined, and then make sure to

Quote:
link the library or include the source file that defines


it.

Share this post


Link to post
Share on other sites
This forward declaration:
int inputs(const int num, const int numb, int Pcent[], const int pcent, char name1[], char name2[], char name3[], char name4[]);

Does not match this implementation:
int inputs(const int num, const int numb, char name1[], char name2[], char name3[], char name4[]){

The compiler can't find the first function, because it doesn't exist.

Share this post


Link to post
Share on other sites
OMG!!!!!!!

DUH!!!!!
thanks Evil Steve

well i guess that is what i get for staying up for 72 hours....
time for some more coffee...

sighs, i feel like such and id10t...
as they say "cant see the forest though the trees"
"the closer your to a problem, the harder it is to see."

oh and thanks you everyone for helping....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!