[SOLVED] How do I fill char array or string?

Seems like a basic need, but I can't find any examples :frowning:
I want to change contents of the char array, switch text for another. Here's code example (just filling myDate with 12 "x" characters:

char myDate[]={"Jan 01, 2001"};
void setup() {
   Serial.begin (9600);
}
void loop() {
   for (int i=0;i<12;i++){
   myDate[i]="x";
  }
  for (int i=0;i<5;i++){
    Serial.print (myDate[i]);
    delay (500);
  }
  Serial.println (" ");
}

But getting: 6: error: invalid conversion from 'const char*' to 'char'

Please help!

chars are surrounded by single quotes, not double.

There are several ways to populate char arrays (and strings). As Arrch points out, using a char to fill an element in the array is one way.

Using strcat() and memset() are others, depending on what you want to set the array to, and how much of the array you want to overwrite.

Aaaaaaah, thank you guys!!! :slight_smile: I can't believe it was so simple, I've been banging my head on the desk for about an hour trying to figure why this simple code doesn't work. Single quotes, who knew? :slight_smile: It works now.
And I will look into strcat() and memset() as well!

Single quotes, who knew?

Well, Arrch did.

PaulS:

Single quotes, who knew?

Well, Arrch did.

Hehe, yes of course, that was a rhetorical question :smiley: