Hello there,
first of all, great Forum here. Already helped me alot up until now. However, there is one thing right now I can't seem to figure out, which is why I decided to make my first post here.

Well, the Problem is probably due to the fact that I'm quite new to C programming. Up until now, I only had a little bit of C++ experience and now, I really do miss those strings...

As far as I found out, strings do not exist in C, therefore I have been trying to use char[]. Now, basically that worked for me, but there's something strange.

I tried to create a Program that would read a GPS String from a UART (it's something for an ATmega128 based Board). For that, I would read every single character into a char Variable and then strncat that into a char[]. In theory, it works up to the point where the first string is completely send and I want to start a second.

First of all, here's the important part of the code:

Code:
char gpsGPRMC[7]="$GPRMC";
char gpsHeader[7];
char fromUART[2];
char	s0[100];

fromUART[1]='\0';

if ( UART1_IsCharAvailable() ) { 
	fromUART[0]= UART1_GetChar();
	strncat(s0, fromUART, 1);	
	fprintf(u0, "String Length: '%d' - Size: '%d' \n", strlen(s0), sizeof(s0));
	if (fromUART[0]=='\n') {
		fprintf(u0, "\n %s \n",s0);
		s0[0]='\0';
        }
}
Now, there are a few things wrong with this (I think). You can see that I already print out the String Length and it's size...

The String I send is: $GPRMC,142430.031,A,4936.8213,N,00611.9255,E,58.17 ,240.09,170609,,*31

The Characters are well received and put in the fromUART Variable. I once did a fprintf of that to check, all worked well. They then get concatenated into the s0 Variable. That seems to work reasonably well the first time. Then I try to empty the "string" with setting the first byte to '\0' and start all over again. However, this "emptying" does not seem to work. At least, he seems to keep a few things from the content, thus leading to a corrupted String. And, furthermore, after two cycles, the program seems to stop. Since it's running on the ATmega128, I don't really get any precise feedback, but I suppose it's the s0 variable that grows way too big. That's why I did the printout of Size and Length. And indeed, I get something like this:

String Length: '206' - Size: '100'
String Length: '207' - Size: '100'
String Length: '208' - Size: '100'
String Length: '209' - Size: '100'
String Length: '210' - Size: '100'
String Length: '211' - Size: '100'
String Length: '212' - Size: '100'
String Length: '213' - Size: '100'
String Length: '214' - Size: '100'
String Length: '215' - Size: '100'
String Length: '216' - Size: '100'
String Length: '217' - Size: '100'
String Length: '218' - Size: '100'
String Length: '219' - Size: '100'
String Length: '220' - Size: '100'
String Length: '221' - Size: '100'
String Length: '-4129' - Size: '100'
String Length: '-35526116450z' - Size: '100'
String Length: '-52481762740F' - Size: '100'
String Length: '-35526116450z' - Size: '100'
String Length: '-41985410275p' - Size: '100'
String Length: '-46022468915P' - Size: '100'
String Length: '-41177998547' - Size: '100'

etc, etc...

And the String itself is somewhat corrupted.

I then changed things to

Code:
char *s0="";
Which gave me an output of:

String Length: '1' - Size: '2'
String Length: '1' - Size: '2'
String Length: '1' - Size: '2'
String Length: '1' - Size: '2'
String Length: '1' - Size: '2'

...

Which is ... wrong... too.

So I'm kinda lost here. What in the World do I to terribly wrong? Anyone got an Idea? Or can put me on the right path?

Thanks already!!