I'm new to using MinGW and C++ in general, and whenever try compile my source file, the executable seemingly does nothing, even though it should output a simple "Hello World!". I've tried commenting out the lines that use vector, and it'd output "Hello World!" just fine.
Source code which doesn't seem to do or output anything:
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
const int LIMIT = 1000000; // one million
int main(int argc, char *argv[])
{
int* arr = new int[LIMIT] {0};
vector<int>* v = new vector<int>();
cout << "Hello World!" << endl;
delete v;
return 0;
}
Source code with vector commented out that outputs "Hello World!" just fine:
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
const int LIMIT = 1000000; // one million
int main(int argc, char *argv[])
{
int* arr = new int[LIMIT] {0};
// vector<int>* v = new vector<int>();
cout << "Hello World!" << endl;
// delete v;
return 0;
}
Both are compiled and run with:
C:\Users\User\my\directory\src> g++ source.cpp -o source.exe -std=c++11
C:\Users\User\my\directory\src> ./source.exe
Compiling and running either doesn't produce any error message. Note that #include <vector> remains uncommented in both instances.
Aucun commentaire:
Enregistrer un commentaire