int main() { int size; std::cin >> size; int *array = new int[size]; delete [] array; return 0; }
Don’t forget to delete
every array you allocate with new
.
Related Posts:
- C++ convert from 1 char to string?
- Pause Console in C++ program
- What is the easiest way to initialize a std::vector with hardcoded elements?
- Vector of Vectors to create matrix
- std::string to char*
- How to generate a random number in C++?
- Why are #ifndef and #define used in C++ header files?
- What does int argc, char *argv[] mean?
- Meaning of = delete after function declaration
- Using NULL in C++?
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- C++ Error: undefined reference to `main’
- 1.#QNAN error C++
- What is the array form of ‘delete’?
- Error: Expression must have integral or unscoped enum type
- Use new operator to initialise an array
- Remove secure warnings (_CRT_SECURE_NO_WARNINGS) from projects by default in Visual Studio
- Undefined Symbols for architecture x86_64: Compiling problems
- “No viable overloaded ‘=’ ” why?
- Check if a string contains a string in C++
- Efficient way to return a std::vector in c++
- “No viable overloaded ‘=’ ” why?
- Replace part of a string with another string
- What does “<<" and ">>” mean in C++ for cout/cin?
- C ++ error: a expected initializer before [function name]
- invalid new-expression of abstract class type
- std::string to char*
- Does the ‘mutable’ keyword have any purpose other than allowing the variable to be modified by a const function?
- SDL2.DLL missing
- Argument list for class template is missing
- Fastest way to check if a file exist using standard C++/C++11,14,17/C?
- Cleanest way to copy a constant size array in c++11
- Difference between using Makefile and CMake to compile the code
- Exception Error c0000005 in VC++
- push_back vs emplace_back
- Press Enter to Continue
- How to trim a std::string?
- Parsing a comma-delimited std::string
- Random number c++ in some range
- “g++” is not recognized as an internal or external command, MinGW
- Compiling a C++ program with gcc
- C++ BlackJack Stuck trying to program Ace
- Convert a String In C++ To Upper Case
- How do I add the MinGW bin directory to my system path?
- What’s the syntax for declaring an array of function pointers without using a separate typedef?
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- Sorting Linked List C++ with pointers
- Get Unix timestamp with C++
- Class prototyping
- How to dynamically allocate an array of pointers in C++?
- How do I compile C++ to JavaScript in a browser?
- Is the sizeof(some pointer) always equal to four?
- How do you initialise a dynamic array in C++?
- What are the distinctions between the various symbols (*,&, etc) combined with parameters?
- Accessors and Mutators C++
- Error C1083: Cannot open include file: ‘stdafx.h’
- C++ Simple hangman game
- “The system cannot find the file specified” when running C++ program
- Remove First and Last Character C++
- C++ Convert string (or char*) to wstring (or wchar_t*)
- Program received signal SIGSEGV, Segmentation fault
- Integer to hex string in C++
- Comparison of C++ unit test frameworks
- What is the difference between .cc and .cpp file suffix?
- C++ error: object of abstract class type is not allowed: pure virtual function has no overrider
- Correct way to work with vector of arrays
- What’s the difference between nexti and stepi in gdb?
- How to get current time in milliseconds?
- Resizing dynamic array in c++
- C++ – Nested include – Avoiding ‘include nested too deeply error’
- Reading data from file into an array
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- Trying to use int in getline
- c++ error c2015: too many characters in constant
- Splitting a C++ std::string using tokens, e.g. “;”
- Py_Initialize fails – unable to load the file system codec
- C++ pass an array by reference
- error LNK2019: unresolved external symbol “” referenced in function
- Undefined reference to a static member
- How to sort with a lambda?
- stoi function gives error: std::invalid_argument at memory location 0x0035E8D8. c++
- Using G++ to compile multiple .cpp and .h files
- LPCSTR, LPCTSTR and LPTSTR
- How to do std::string indexof in C++ that returns index of matching string?
- variable or field declared void
- Invalid conversion from ‘char’ to ‘const char *’
- How do I deal with “signed/unsigned mismatch” warnings (C4018)?
- Creating folders in C++
- Unrecognizable template declaration/definition
- MSVCP120d.dll missing
- Modulo operator with negative values [duplicate]
- heap corruption detected | C++
- Update g++ but still old version
- module unsafe for SAFESEH image C++
- Why are there two different getline() functions (if indeed there are)?
- Whats the difference between UInt8 and uint8_t
- Struct with template variables in C++
- error: no member function declared in class
- Why does my program give “NULL used in arithmetic”
- no matching function to call for “getline”