943,654 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1995
  • C++ RSS
Aug 11th, 2005
0

Annoying link errors

Expand Post »
Hey, i get the following annoying link errors when i try to build my program:
Quote ...
Compiling...
power level.cpp
Linking...
power level.obj : error LNK2001: unresolved external symbol "int __cdecl YesNo(void)" (?YesNo@@YAHXZ)
Debug/power level.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
The program compiles ok, but it wont build, for those who need to see the code, here is the snippet where YesNo is an integer:

C++ Syntax (Toggle Plain Text)
  1. int YesNo(), y, n, yes, no, h;
  2. cout<<"Are you a Human? Enter y or n for yes or no."<< endl;
  3. cin>> y, n, yes, no, YesNo();
  4. int check;
  5. scanf(" %c", &check);
  6. if (check=='Y'||check=='y'||check=='yes'||check=='Yes')
  7. {
  8. h = z*2;
  9. cout<<"Your human zenii reading is " << h << ".\a" << endl;
  10. cout<< ""<< endl;
  11. cout<<"Goodbye, " << name << "."<< endl;
  12. cin>> quit;
  13. system("cls");
  14. return 0;
  15. }
  16. else if (check=='N'||check=='n'||check=='no'||check=='No')
  17. cout<< ""<< endl;
  18. cout<<"Goodbye, " << name << "."<< endl;
  19. cin>> quit;
  20. system("cls");
  21. return 0;
  22. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Aug 11th, 2005
0

Re: Annoying link errors

Where do you define the function YesNo()?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Aug 11th, 2005
0

Re: Annoying link errors

I didnt =/, i thought it was included in a library, heres the full code if you want to take a look
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <cmath>
  3. #include <stdio.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. system("title AnimeDD RPG Calculator");
  10. system("color 8E");
  11. int value = 0;
  12. cout << "Enter 0 to calculate your Power Level (Battle/Training)" << endl;
  13. cout << "Enter 1 to calculate your Zenii (Storyline)" << endl;
  14. cin >> value;
  15. {
  16. char name [100];
  17. char quit;
  18. quit ='\0';
  19. while (quit !='q')
  20.  
  21. if(value == 0)
  22. {
  23. system("title AnimeDD Power Level Calculator");
  24. double creat, diff, lines, pl, x, y, z; //loads integers into memory
  25. cout <<"This is a simple power level calculator"<< endl;
  26. cout<<"What is your characters name?"<< endl;
  27. cin>> name; (name,100);
  28. cout<<"Hello, " << name << "."<< endl;
  29. cout<<"Put in your current pl"<<endl;
  30. cin>> pl;
  31. cout<<"Put in your difficulty points:"<< endl; //asks for diff
  32. cin>> diff; //Receives difficulty and loads it into memory
  33. cout<<"Put in your creativity points:"<< endl;
  34. cin>> creat;
  35. cout<<"Put in your line count:"<< endl;
  36. cin>> lines;
  37. x = pl*((10*diff)+(10*creat)+(2*lines));
  38. y = x/(150*(log(pl/1.5)));
  39. z = pl+y;
  40. cout<<"Your Power level is " << z << ".\a" << endl;
  41. cout<<""<< endl;
  42. cout<<"Q - Quit"<< endl;
  43. cout<<"R - Repeat"<< endl;
  44. cout<<"Please type in the corresponding letter for your choice then press enter."<< endl;
  45. cin>> quit;
  46. cout<<"Goodbye, " << name << "."<< endl;
  47. system("PAUSE");
  48. system("cls");
  49. return 1;
  50. }
  51. else if(value == 1)
  52. {
  53. system("title AnimeDD Zenii Calculator");
  54. system("color 8E");
  55. cout <<"Alright time to calculate your Zenii, get your storyline ratings ready!" << endl;
  56. int lines, creat, x, o, z;
  57. cout<<"What is your characters name?"<< endl;
  58. cin>> name; (name,100);
  59. cout<<"Hello, " << name << "."<< endl;
  60. cout<<"Put in your creativity rating for the storyline post"<< endl;
  61. cin>> creat;
  62. cout<<"Thank you, Now put in your line count for the storyline post"<< endl;
  63. cin>> lines;
  64. x = creat*creat*creat;
  65. o = lines*20;
  66. z = x+o;
  67. cout<<"Your zenii for this post is " << z << ".\a" << endl;
  68. int YesNo(), y, n, yes, no, h;
  69. cout<<"Are you a Human? Enter y or n for yes or no."<< endl;
  70. cin>> y, n, yes, no, YesNo();
  71. int check;
  72. scanf(" %c", &check);
  73. if (check=='Y'||check=='y'||check=='yes'||check=='Yes')
  74. {
  75. h = z*2;
  76. cout<<"Your human zenii reading is " << h << ".\a" << endl;
  77. cout<< ""<< endl;
  78. cout<<"Goodbye, " << name << "."<< endl;
  79. cin>> quit;
  80. system("cls");
  81. return 0;
  82. }
  83. else if (check=='N'||check=='n'||check=='no'||check=='No')
  84. cout<< ""<< endl;
  85. cout<<"Goodbye, " << name << "."<< endl;
  86. cin>> quit;
  87. system("cls");
  88. return 0;
  89. }
  90. }
  91. return 0;
  92. }
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Aug 11th, 2005
0

Re: Annoying link errors

> I didnt =/, i thought it was included in a library
Well, you'll need to define one then, or else don't use it.
C++ Syntax (Toggle Plain Text)
  1. int YesNo(), y, n, yes, no, h;
  2. cout<<"Are you a Human? Enter y or n for yes or no."<< endl;
  3. cin>> y, n, yes, no, YesNo();
Oy! There's a lotta weird strangeness going on there.

[edit]It looks like you tried to grab this function here. Poke around up that thread a bit and see how that code got working.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Aug 11th, 2005
0

Re: Annoying link errors

Lol its for an rpg, if your character is a human you get double zenii for a post
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Aug 11th, 2005
0

Re: Annoying link errors

No, I meant this stuff.
		int YesNo(), y, n, yes, no, h;
		cout<<"Are you a Human? Enter y or n for yes or no."<< endl;
		cin>> y, n, yes, no, YesNo();
Declaring a function prototype along with variables. Unusual.
This looks like a creature from another language with all the successive use of the comma operator.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Aug 11th, 2005
0

Re: Annoying link errors

What should i define YesNo() as then?
I just need to to put in a y, n, yes or no and have it recognise it and do it based on the check function, can you suggest anything?
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Aug 11th, 2005
0

Re: Annoying link errors

Perhaps you missed my edit.
Quote originally posted by Dave Sinkula ...
[edit]It looks like you tried to grab this function here. Poke around up that thread a bit and see how that code got working.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Aug 11th, 2005
0

Re: Annoying link errors

Oh sorry i missed that,
i changed the int check to char check because getint doesnt work, and removed the check for Yes and yes because they arent chars,
its now
C++ Syntax (Toggle Plain Text)
  1. char check;
  2. scanf(" %c", &check);
  3. getchar();
  4. if (check=='Y'||check=='y')
and looks like everythings running perfectly, i took out the YesNo() aswell because it overly wasnt needed, thanks alot for your help.
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: bin trees
Next Thread in C++ Forum Timeline: Singly-Linked Lists: Ultimate





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC