#Visual Studio Issue(I'm not sure myself)

20 messages · Page 1 of 1 (latest)

slow radish
#

I was doing some homework and I noticed VS seems to not run my code, giving errors.
The same code can be ran through an online compiler and work.

agile yewBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

#

@slow radish

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

vapid saddle
#

Variable length arrays are a (cursed) gcc extension and are not valid C++

#

You should be using a vector, or a fixed sized array

slow radish
#

My homework asks for it to be variable, so I'm unsure what to do now.

#

I'm supposed to build an array

vapid saddle
#

a vector is dynamically sized

#

if you're not allowed to use them, you'll have to heap allocate it with new[] and delete[]

slow radish
#

I'll be honest, I am very much confused by what you're telling me.

vapid saddle
#

you cannot do ```cpp
int n;
std::cin >> n;
int a[n];

in C++, it isn't valid
#

so you need to do it another way. Have you seen vectors or manual memory management?

slow radish
#

Yes, I did learn about vectors.

vapid saddle
#

that's what you need to use instead

slow radish
#

I'll try and see what I can do.

#

Thanks and sorry for taking up your time.

agile yewBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

vapid saddle
#

you're welcome, good luck raldHeart

slow radish
#

Jesus Christ, am I dumb

#

I just had to replace the n with the maximum value allowed for n to have.