Your bracketing is broken. The net result is that you are attempting to define your main
function inside ciong
. And C++ does not support nested function definitions. Hence the compiler error.
The code should be:
#include "stdafx.h" #include <iostream> using namespace std; int ciong(int n) { switch (n) { case 1: return 1; break; case 2: return 2; break; default: int pomocniczaLiczba = ciong(n - 2) + ciong(n - 1) * ciong(n - 1); return pomocniczaLiczba; break; } } // <----- Oops, this was missing in your code int main() { int n; cin >> n; cout << ciong(n) << endl; return 0; }
And there are other bugs. For example, you meant cout << ciong(n)
.
Related Posts:
- Unresolved external symbol in object files
- Unresolved external symbol in object files
- How to use _CRT_SECURE_NO_WARNINGS
- Windows 7 exception code: 0xc0000409
- Difference between ‘strcpy’ and ‘strcpy_s’?
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- Exception Error c0000005 in VC++
- Visual Studio debugger error: Unable to start program Specified file cannot be found
- Identifier is undefined
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- Win32 Console Application
- https://stackoverflow.com/questions/3865946/error-generic-array-creation
- C++ Compiler Error C2280 “attempting to reference a deleted function” in Visual Studio 2013 and 2015
- cin.eof() functionality
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- error LNK2019: unresolved external symbol “” referenced in function
- LPCSTR, LPCTSTR and LPTSTR
- error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- Download c++ in existing visual studio 2017
- module unsafe for SAFESEH image C++
- Unexpected end of file error
- ld: symbol(s) not found for architecture x86_64 error
- C++ string to double conversion
- How do I print out the contents of a vector?
- ‘was not declared in this scope’ error
- Good input validation loop using cin – C++
- C++ for each, pulling from vector elements
- How do I erase an element from std::vector<> by index?
- Why use ‘glad’ library for opengl initialization? [duplicate]
- What does `*&` in a function declaration mean?
- (->) arrow operator and (.) dot operator , class pointer
- How to reverse an std::string? [duplicate]
- What is the C version of RMI
- What is uintptr_t data type
- const int = int const?
- Undefined reference to vtable
- In C++, what is a virtual base class?
- What is the difference between a static and const variable?
- What is move semantics?
- unsigned int vs. size_t
- How do I clear a C++ array?
- error: expected primary-expression before ‘)’ token (C)
- What does -> mean in C++?
- How to pass optional arguments to a method in C++?
- How to copy a string of std::string type in C++?
- C++ #include guards
- Is std::stoi actually safe to use?
- C++ forbids variable-size array
- Fill array with random numbers within a specified range (C++)
- Remove an array element and shift the remaining ones
- Right way to split an std::string into a vector
- string subscript out of range error
- push_back vs emplace_back
- No operator << matches these operands
- Returning an empty string : efficient way in c++
- How to find the size of an int[]?
- Append an int to a std::string
- Decimal to hex conversion c++ built-in function
- C++ IDE with repl?
- error: use of deleted function
- expected unqualified-id before string constant
- “function already has a body”
- C++: Access violation writing location
- error: strcpy was not declared in this scope
- how to print a string to console in c++
- How to call a parent class function from derived class function?
- Error: No instance of constructor matches the argument list
- How can I get the list of files in a directory using C or C++?
- RPN Calculator for C++
- What does `Fatal Python error: PyThreadState_Get: no current thread` mean?
- Debug Assertion Failed: _CrtIsValidHeapPointer(block)
- gdb error not in executable format: File format not recognized
- C++ Erase vector element by value rather than by position?
- C++ Class ‘undeclared identifier”
- Destructor for Binary Search Tree
- What is the most popular general purpose C++ framework?
- C++ – include unistd.h: why not cunistd?
- Dynamically allocated string array, then change it’s value?
- Use the auto keyword in C++ STL
- c++ –
- C++ – statement cannot resolve address for overloaded function
- Reading data from file into an array
- Trying to use int in getline
- stoi function gives error: std::invalid_argument at memory location 0x0035E8D8. c++
- Stack around the variable ‘ ‘ was corrupted
- The difference between cin.ignore and cin.sync
- casting int to char using C++ style casting
- How to print (using cout) a number in binary form?
- What is the job of autogen.sh when building a c++ package on Linux
- Using G++ to compile multiple .cpp and .h files
- How to do std::string indexof in C++ that returns index of matching string?
- Modulo operator with negative values [duplicate]
- Finding the type of an object in C++
- C++ Simple Dice roll – how to return multiple different random numbers [duplicate]
- How can I get a file’s size in C++?
- Why can’t I make a vector of references?
- What does “-Wall” in “g++ -Wall test.cpp -o test” do?
- C++ equivalent of StringBuffer/StringBuilder?