const char in write functions for udp, i2c, ethernet

01 Nov 2011

in a number of the write or send functions in the library such as i2c and udp, the data to be transmitted is declared as a const char such as

write

int write( int address, const char * data, int length, bool repeated = false )

Write to an I2C slave

Does not the const char array have to be declared as an initialized value, which is stored in rom verses the plain char array which allows the data to be determined at any time, stored in ram.

01 Nov 2011

I believe, at least the intent, is that const here means that the data is not altered by this function.

IIRC, in the library "strcpy" definition for example the source string is of type "const char *" whereas the destination string is of type "char *". Meaning that the destination string is modified but the source string is not.