I have a very simple code, but still it doesn’t work the way i want it. It should give me back all n which it goes trough, but I only get the last one: “10000001”. What did i wrong?
#include <iostream>
using namespace std;
int main()
{
int n=1000;
int i=1;
for(;i<3;n*=100,i++);
{
cout << ++n << "\n";
int* temp = new int[n];
delete [] temp;
}
return 0;
}
You don’t need the semicolon at the end. You are running an empty loop by doing this.