Hi - I'm new to programming and attempting to replace part of an input string with another string. I'm using a Uno with a CuteDigi Protosheild with a MAX233. I'm inputting/outputting a 9600 baud serial string ($OHPR,xxx.x,xxx.x,xx.x,xx.x*xx) thru the 233 into the Uno using SoftwareSerial.h thru D2 and out thru the USB serial port. I want to replace the beginning '$OPHR' with '$GPXDR'. I can print the sring and strip out the '*xx' but cant seem to figure out how to replace those beginning characters. Any input would be helpful.
Hi - Thanks for the reply. The serial string data does change - the original string is heading, roll, pitch and temp. The $OHPR, does not change and this is what I'd like to replace with $GPXDR.
dscott:
Hi - Thanks for the reply. The serial string data does change - the original string is heading, roll, pitch and temp. The $OHPR, does not change and this is what I'd like to replace with $GPXDR.
That's what I meant, if it's always going to start with "$OHPR", then you can use strncpy() to a new string. If you just wante to print it, use majenko's code.