xcode6 - C++ compiler error in CodeBlocks & Xcode -


i'm learning become programmer , while learning came across bit of problem. program doesn't run , gives me error

clang: error: linker command failed exit code 1 (use -v see invocation)

why , how fix , prevent happening again?

#include <iostream> using namespace std;  void fav(); int main() {     fav();     return 0; } void fav(int x) {     cout<<"troy's favorite number \n"<<x; } 

the declared function , defined function different. therefore different functions, former of never defined, though called in main

void fav();      // declared void fav(int x)  // defined 

you need change signature of declared function matche declared , called function

void fav(int x); int main() {     int x;     cin >> x;     fav(x);     return 0; }  void fav(int x) {     cout<<"troy's favorite number \n" << x; } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -