String address;
for ( int a = 0; a <= 500;) {
address = String(address + a);
int address = a;
a += 2;
}
void setup() {
Serial.begin(9600);
}
void loop() {
}
String address;
for ( int a = 0; a <= 500;) {
address = String(address + a);
int address = a;
a += 2;
}
void setup() {
Serial.begin(9600);
}
void loop() {
}
Your topic was MOVED to its current forum category as it is more suitable than the original as it does not relate specifically to version 2.0 of the IDE
I am not sure exactly what you are trying to do but you cannot create new variables with a numeric subscript like that. It looks like what you need is an array of values
you probably want
int addresses[500]; // indexes go from 0 to 499
for (size_t index =0; index < 500; index ++) {
addresses[index] = 10; // whatever
}
of course you need an arduino with enough RAM to accommodate the 500 integers (it will take 1 KB on a UNO - that's half the available memory)
sound like storing character-sequences that are postage-adresses like
"Lincoln-Boulevard 111 - 12345 Yew York City"
but the whole code looks weird to me.
What is the final purpose of this?
Please give an overview about your project.
It looks like you want:
for (int a = 0; a <= 500; a += 2)
{
address += String(a);
}
That would give you a very long string starting with:
024681012141618202224262830323436384042...
If that is NOT what you want, what DO you want?
I think that's pretty clear.
@kelleci wanted to dynamically create 251 variable names
address0
address2
address4
...
address250
and then define 251 variable of type int with those names
some interpreted programming languages allow for this type of construct/abuse
well if he really would like to do something like that maybe using macros will do the job?
The better approach would be to use something simple as an array
Hence the suggestion in post #3
But indeed would be good for OP to clarify her/his intent
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.