c++ - error LNK2019: unresolved symbol "char_cdecl st(void) -


okay, i've looked around , still not quite understand why getting error. code included below. had older code working fine. decided make perform more 1 calculation per opening of application. after fixing several other errors, 1 popped up. 1 had popped after realized needed ' ' around y.

#include "stdafx.h" #include <cstdio> #include <cstdlib> #include <iostream>  using namespace std; int main(int nnumberofargs, char* pszargs[])  {      int x;     int y;     int result;     char z;     char = 'y';      char st();     {         cout << ("do calculation?: y/n");         cin >> a;         if (a = 'n')         {             system("pause");             return 0;         }     }       while (a = 'y');     {         cout << "symbol here: " <<endl;         cin >> z;         cout << "number 1: " <<endl;         cin >> y;         cout << "number 2: " <<endl;         cin >> x;         if (z == '*')         {             result = x * y;             cout << "answer:" << result <<endl;             st();         }         else if (z == '/')         {             result = x * y;             cout << "answer:" << result <<endl;             st();         }         else if (z == '-')         {             result = x / y;             cout << "answer:" << result <<endl;             st();         }         else if (z == '+')         {             result = x + y;             cout << "answer:" << result <<endl;             st();         }         else if (z == '%')         {             result = y % x;             cout << "answer:" << result <<endl;             st();         }     } } 

you have semi-colon @ end of char st(). declares function not define it. code comes after declaration becomes part of main , gets executed first time start up. why haven't noticed it.

you need move st() out of main local function definitions illegal in c++.

using namespace std;  char st() {     cout << ("do calculation?: y/n");     cin >> a;     if (a = 'n')     {         system("pause");         return 0;     } }   int main(int nnumberofargs, char* pszargs[]) {     int x;     int y;      // ... rest of code      return 0; } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -