Invalid Allocation Size

I get the error- Invalid Allocation Size - for this part of my code:

1
2
3
4
int var;
float *res;
cin>>var;
res=new float[var+1];


Why is it like that and what can I do to fix it?
Is it compile or runtime error?
runtime error
What you have entered?
Because your code should be valid.
2
It should work: http://ideone.com/5y5LlM
Problem is in your compiler or project settings
Thank you very much!
Topic archived. No new replies allowed.