Is their ANY way to do something like:

for (int x=1; x<3; x++) {string MyArray[1][x]={"-"};}

Assuming the array has already been defined? I really don't want to have to do:

MyArray[1]={blah}
MyArray[2]={blah}
MyArray[3]={blah}
etcetera etcetera

I'm not necessarily looking for efficiency but seriously, initializing 50 arrays looks very messy and ugly.

Recommended Answers

Since it's already defined, you already have it, sort of. Just leave the keyword "string" out as well the inner brackets.

for (int x=1; x<3; x++) {MyArray[1][x]="-";}

This is a 2-D string array?

[EDIT]
Actually, I think you have to fill in the "blah", "etcetera", and the declaration …

Jump to Post

All 2 Replies

Since it's already defined, you already have it, sort of. Just leave the keyword "string" out as well the inner brackets.

for (int x=1; x<3; x++) {MyArray[1][x]="-";}

This is a 2-D string array?

[EDIT]
Actually, I think you have to fill in the "blah", "etcetera", and the declaration so it's clear what you're trying to do.
[/EDIT]

Actually, I think you have to fill in the "blah", "etcetera", and the declaration so it's clear what you're trying to do.

D:

I forgot what I was going to do... What will we do now?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.