Skip to main content
added 5 characters in body
Source Link
st2000
  • 7.5k
  • 2
  • 13
  • 20

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

added later...

Sorry, of course there is noThe method "printf" is normally not used in Arduino land. So that for"for" loop would look more like:

for(i = 0; i < num_states; i++) 
{
 Serial.println("state ");
 Serial.println(i)
 Serial.println(states[i]);
}

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

added later...

Sorry, of course there is no "printf" in Arduino land. So that for loop would look more like:

for(i = 0; i < num_states; i++) 
{
 Serial.println("state ");
 Serial.println(i)
 Serial.println(states[i]);
}

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

added later...

The method "printf" is normally not used in Arduino land. So that "for" loop would look more like:

for(i = 0; i < num_states; i++) 
{
 Serial.println("state ");
 Serial.println(i)
 Serial.println(states[i]);
}
deleted 2 characters in body
Source Link
st2000
  • 7.5k
  • 2
  • 13
  • 20

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

added later...

Sorry, of course there is no "printf" in Arduino land. So that for loop would look more like:

for(i = 0; i < num_states; i++) 
{
 Serial.println("state ");
 Serial.println(i)
 Serial.println(states[i]);
}

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

added later...

Sorry, of course there is no "printf" in Arduino land. So that for loop would look more like:

for(i = 0; i < num_states; i++) 
{
 Serial.println("state ");
 Serial.println(i)
 Serial.println(states[i]);
}
deleted 2 characters in body
Source Link
st2000
  • 7.5k
  • 2
  • 13
  • 20

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

Let's just deal with character strings.

The truth of the matter is that Arduino programming uses the language C. C is very common and you can search for help in many places.

There are several ways to deal with strings in C. In this example we are using an array of pointers to strings:

// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:

state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.

Source Link
st2000
  • 7.5k
  • 2
  • 13
  • 20
Loading