Making an Array for declaring a set of strings

Hello,

I am trying to make an array to replace this code:

String x1 = 0;
String x2 = 0;
String x3 = 0;
String x4 = 0;
String x5 = 0;
String x6 = 0;
String x7 = 0;
String x8 = 0;
String x9 = 0;
String x10 = 0;
String x11 = 0;
String x12 = 0;
String x13 = 0;

However i’m having troubles creating it. I made the following code:

int numberofStrings = 13;
for (int stringNumber = 1; stringNumber  < numberofStrings ; stringNumber ++)
{
  String (x[stringNumber ] = 0);
}

I also tryed it with:

int numberofStrings = 13;
for (int stringNumber = 1; stringNumber < numberofStrings ; stringNumber ++)
{
  pinMode (x[stringNumber ] = 0, String);
}

Both versions give me the following error: “expected unqualified-id before ‘for’”

How do i fix this? Any help is much appreciated.

How do i fix this?

Executable code needs to be in a function. Your snippets don’t appear to be inside a function.

for (int stringNumber = 1; stringNumber  < numberofStrings ; stringNumber ++)
{
  String (x[stringNumber ] = 0);
}

Is x an array? What good is it to create a String object from the value 0 that you are assigning to the x array, when you then discard the String instance created?

You can NOT use a function to create, at run time, a bunch of named String objects. Names don’t exist at run time.

PaulS:

How do i fix this?

Executable code needs to be in a function. Your snippets don’t appear to be inside a function.

for (int stringNumber = 1; stringNumber  < numberofStrings ; stringNumber ++)

{
  String (x[stringNumber ] = 0);
}



Is x an array? What good is it to create a String object from the value 0 that you are assigning to the x array, when you then discard the String instance created?

You can NOT use a function to create, at run time, a bunch of named String objects. Names don't exist at run time.

x is not an array. I just want to make a set number of strings with a function, instead of copyng and pasting the same line over and over.This would enable me just enter the number of strngs that have to be created. It should have a form like this:

String "x"[numbers from 0 to max] = 0;

I did not understand what you tryed to explain to me, since my knowledge of programming is very basic.

I just want to make a set number of strings with a function

You probably need an array - I'm not sure why a function should be required.

An Array would do the trick i think, but I have failed in creating a working array for it.

An important thing to remember is that array subscripts start at zero, not one.

An Array would do the trick i think, but I have failed in creating a working array for it.

You've also failed to post any code that illustrates any problem(s).