Go Down

Topic: What does the F() do exactly? (Read 7 times) previous topic - next topic

ninja2



Could this F() syntax be used in place of rather cumbersome:
    strcpy_P(buffer, (char*)pgm_read_word(&(str_table[index])));


This may help...
http://arduiniana.org/libraries/flash/


can you clarify the origin of the F() syntax, is it from Mikal Hart's Flash library, or is it part of C or the standard IDE ?

Coding Badly

can you clarify the origin of the F() syntax, is it from Mikal Hart's Flash library


That's how I was introduced to it.

ninja2

so:
(and this may seem a very dumb question)

if (I don't include the flash library in my sketch)
  { F() will not work? ;}
endif

mromani

This sketch compiles and runs, so the answer seems to be no, one doesn't have to (explicitly) include Flash library to use F().

Code: [Select]

// F test

void setup() {
    Serial.begin(9600);
   
    Serial.println(F("STRINGA 1"));
    Serial.println(F("STRINGA 2"));
}

void loop() {
}


ninja2

doh! I could've done that ... excellent way to resolve my query, thanks mromani

Go Up