This is the mail archive of the
ecos-devel@sources.redhat.com
mailing list for the eCos project.
strcat breaks printf
- From: Wayne Gemmell <wayneg at ananzi dot co dot za>
- To: ecos-devel at sources dot redhat dot com
- Date: Tue, 17 Aug 2004 00:04:48 +0200
- Subject: strcat breaks printf
- Reply-to: wayneg at ananzi dot co dot za
Hi all
I am writing my first embedded software on ecos. I am also new to C I'm a REAL
newb. My problem is with the following code...
<code>
smsBody = malloc(161);
tmpStr = malloc(100);
reset_log_read();
smsBody = "tcc";
puts("Hello");
for (j=0;j < 1;j++)
{
tmpTime = rec->timestamp;
puts("Hello");
sprintf(tmpStr,";%d:%f:%f\0",(unsigned int) tmpTime,
(float)rec->la,(float) rec->lo);
printf("tmp : %s\n",tmpStr);
strcat(smsBody,tmpStr);
}
puts("Hello");
</code>
And my output is as follows...
Hello
Hello
tmp : ;78453:-2614.993896:2822.247070
78453:-2614.993896:2822.247070
707078453:-2614.993896:2822.247070
This is the smsBody output from further on in the program.
tcc;78453:-2614.993896:2822.247070
So the above seems to work. I just don't understand the garbage output
whenever I use puts or printf.
Could anyone give me any pointers?
Regards
Wayne Gemmell