Invalid Allocation Size

Jun 5, 2013 at 2:58pm
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?
Jun 5, 2013 at 3:05pm
Is it compile or runtime error?
Jun 5, 2013 at 3:28pm
runtime error
Jun 5, 2013 at 3:41pm
What you have entered?
Because your code should be valid.
Jun 5, 2013 at 4:47pm
2
Jun 5, 2013 at 4:49pm
It should work: http://ideone.com/5y5LlM
Problem is in your compiler or project settings
Jun 5, 2013 at 5:03pm
Thank you very much!
Topic archived. No new replies allowed.