char myStr[] = "this is a test";
int i;
void setup(){
Serial.begin(9600);
}
void loop() {
for (i = 0; i < sizeof(myStr) - 1; i++){
Serial.print(i, DEC);
Serial.print(" = ");
Serial.write(myStr[i]);
Serial.println();
}
delay(5000); // slow down the program
}
Hi PoleMac,
I believe your code doesn't reflect your intentions sizeof(myStr) reports the size of myStr, which is a pointer indeed.
What you want to do is calling strlen(myStr), which returns the actual size of the string.
warning: comparison between signed and unsigned integer expressions
strlen returns unsigned. your counter i is signed. This will probably still work, but if you want to get rid of the warning, just use "unsigned int" for your loop counter.
I want to do something like this :
char myStr[] = {"this is a test", "testing 123", "working"};
This code only works regular Arduino & WeMos D1.
I don't think this has anything to with Arduino101, since this line is just incorrect C++. Try this instead;
const char *myStr[] = {"this is a test", "testing 123", "working"};