Concatenation errors with Adafruit GPS

Hello guys, i am using the GPS from adafruit and i am trying to write some values to a file in a single string line form. I am experiencing errors with the following line:

String dataString = GPS.hour + ":" + GPS.minute + ":" + GPS.seconds + " " + GPS.day + "/" + GPS.month + "/" + GPS.year + " " + GPS.latitudeDegrees + " " + GPS.longitudeDegrees + " " + GPS.speed*1.852 + " " + GPS.altitude;

The error message i receive is the following:

parsing-mega:160: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'

I have tried to fiddle with the line in order to understand where is the issue. The following line runs without errors

String dataString = GPS.hour + ":" + GPS.minute;

Even by adding the seconds brings an error. I am a bit confused. Thank you in advance and i hope i will be able to find an answer here

i am trying to write some values to a file in a single string line form.

Stop it. There is NO benefit to be gained in doing that. NONE.

i am using that string to save it as line in a txt. i am waiting for suggestions and an explanation for your opinion. thank you :slight_smile:

Use sprintf() instead.
http://www.cplusplus.com/reference/cstdio/sprintf/

Don't use String

horussjr:
i am using that string to save it as line in a txt. i am waiting for suggestions and an explanation for your opinion. thank you :slight_smile:

Writing to a file on an SD card is already buffered. Your creation of another (highly inefficient) buffer will not save memory, reduce code, speed up writing to a file, or achieve stiffer erections.

So quit wasting time and resources trying.

maybe i should have mentioned that i am not very familiar with C/C++/Arduino. maybe that would have resulted in some better reactions. anyhow your help is much appreciated. thank you