<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Trouble with strcat - C++ - tribe.net</title>
    <link>http://cpp.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b?format=rss</link>
    <description>Tribe.net. Local Connections</description>
    <item>
      <title>Re: Caution - STRCPY Library is dangerous</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#96e40d5e-2cfa-4ca5-8641-706ae037d99a</link>
      <description>Jason,&#xD;
&#xD;
Right on -- that's what I was trying to say by stating that strings are safer when using C++-specific ways of dealing with them.  If you can't, though -- use the strnX functions instead of the strX ones ... but really, just make your life easier and use C++ strings (std::string and friends).&#xD;
&#xD;
Regards,&#xD;
&#xD;
John&#xD;
&#xD;
Falling You - exploring the beauty of voice and sound&#xD;
http://www.fallingyou.com</description>
      <pubDate>Fri, 03 Feb 2006 04:32:04 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#96e40d5e-2cfa-4ca5-8641-706ae037d99a</guid>
      <dc:creator>John Michael</dc:creator>
      <dc:date>2006-02-03T04:32:04Z</dc:date>
    </item>
    <item>
      <title>Caution - STRCPY Library is dangerous</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#aa7d3f90-fc1d-4d2d-93af-12cb84e6ee16</link>
      <description>As a side-note many of the strcpy library functions are considered dangerous due to their naivete with respect to buffer overflow security attacks.  These days, if you are programming anything serious, its important to a moment to understand them and use safe variations where appropriate.&#xD;
&#xD;
https://buildsecurityin.us-cert.gov/portal/article/knowledge/coding_rules/RULE_0149.xml</description>
      <pubDate>Fri, 03 Feb 2006 02:56:09 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#aa7d3f90-fc1d-4d2d-93af-12cb84e6ee16</guid>
      <dc:creator>Jason</dc:creator>
      <dc:date>2006-02-03T02:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with strcat</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#7a80b824-898b-4f80-9dca-d9aa087783a8</link>
      <description>http://www.gotfuturama.com/Multimedia/EpisodeSounds/4ACV06/03.mp3</description>
      <pubDate>Thu, 02 Feb 2006 05:23:26 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#7a80b824-898b-4f80-9dca-d9aa087783a8</guid>
      <dc:creator>Jon</dc:creator>
      <dc:date>2006-02-02T05:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with strcat</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#e5daaf20-d3f4-4091-8595-e14bcd426b4e</link>
      <description>WTL,&#xD;
&#xD;
If you're going to go C++, things get a lot better (once you get comfy with C++, it can be a lot different than C) -- streams are much safer than char arrays, and ostringstream is much safer than sprintf.&#xD;
&#xD;
Regards,&#xD;
&#xD;
John&#xD;
&#xD;
Falling You - exploring the beauty of voice and sound&#xD;
http://www.fallingyou.com</description>
      <pubDate>Thu, 02 Feb 2006 01:50:43 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#e5daaf20-d3f4-4091-8595-e14bcd426b4e</guid>
      <dc:creator>John Michael</dc:creator>
      <dc:date>2006-02-02T01:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with strcat</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#a0d7f7d1-c84f-4417-aa6e-bf1ff00010ec</link>
      <description>As a bit of a follow up, thanks for the pointers folks.  I managed to beat the code with a stick long enough to get it to do what I wanted.  &#xD;
&#xD;
And then a few days later (of course) , the client changed the requirement that it be done in C and asked for additional functionality, so I re-wrote it in Perl. &#xD;
&#xD;
But, I went out and picked up a newer C++ manual and see what I was doing wrong.  Thanks again!</description>
      <pubDate>Wed, 01 Feb 2006 20:41:30 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#a0d7f7d1-c84f-4417-aa6e-bf1ff00010ec</guid>
      <dc:creator>WTL</dc:creator>
      <dc:date>2006-02-01T20:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with strcat</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#616098de-e1f5-4122-9fc4-949da2698dbe</link>
      <description>also if you force it to compile by using casts or taking the addr of it you will likely crash.  You have only a single byte reserved for your "string" so anything concatenated on the end of it would overwrite memory it hadn't reserved.</description>
      <pubDate>Sat, 14 Jan 2006 06:51:48 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#616098de-e1f5-4122-9fc4-949da2698dbe</guid>
      <dc:creator>Hypno</dc:creator>
      <dc:date>2006-01-14T06:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with strcat</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#fe9f496e-5178-4e75-a0f0-e08c1d70f702</link>
      <description>WTL,&#xD;
&#xD;
... oh, and just to make sure, this is a really common error with beginning C and C++ developers.  I remember running into the very same thing when I first learned C, waaaay back in 1986 on an Atari 1040ST (I believe it was the Metacompco C compiler).&#xD;
&#xD;
Anyway, what Jon says is also true -- sprintf can be your friend here as well.&#xD;
&#xD;
Regards,&#xD;
&#xD;
John, who interestingly enough is on a straight-C project currently (adding functionality to the VideoLAN client)&#xD;
&#xD;
Falling You - exploring the beauty of voice and sound&#xD;
http://www.fallingyou.com</description>
      <pubDate>Sat, 14 Jan 2006 03:36:49 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#fe9f496e-5178-4e75-a0f0-e08c1d70f702</guid>
      <dc:creator>John Michael</dc:creator>
      <dc:date>2006-01-14T03:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with strcat</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#ae109db8-53de-4704-a2ea-3f0433250e83</link>
      <description>sprintf() is also a powerful concatenation function.</description>
      <pubDate>Sat, 14 Jan 2006 03:13:50 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#ae109db8-53de-4704-a2ea-3f0433250e83</guid>
      <dc:creator>Jon</dc:creator>
      <dc:date>2006-01-14T03:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with strcat</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#1f5cce1b-845e-4b3b-ac89-c22aabc58702</link>
      <description>WTL,&#xD;
&#xD;
I believe strcat() takes char *'s as arguments, which is why it's complaining -- a char isn't a char *.  Also, strcat expects the source strings to be null-terminated.  The following example illustrates one usage:&#xD;
&#xD;
#include &amp;amp;lt;stdio.h&gt;&#xD;
#include &amp;amp;lt;stdlib.h&gt;&#xD;
#include &amp;amp;lt;string.h&gt;&#xD;
&#xD;
int main( int iArgc, char *pArgv[] )&#xD;
{&#xD;
  char *cA = "A";&#xD;
  char *cB = "B";&#xD;
&#xD;
  char cDest[10] = {0};&#xD;
&#xD;
  strcat( cDest, cA );&#xD;
  strcat( cDest, cB );&#xD;
&#xD;
  printf( "%s\n", cDest );&#xD;
&#xD;
  return 1;&#xD;
}&#xD;
&#xD;
PugsleyButt:~/devstuff/c jmzorko$ gcc strcat.c -o strcat&#xD;
PugsleyButt:~/devstuff/c jmzorko$ ./strcat &#xD;
AB&#xD;
&#xD;
I hope this helps.  BTW, the string handling in C++ is much better than that in C, but yeah, sometimes ya just got no choice!&#xD;
&#xD;
Regards,&#xD;
&#xD;
John&#xD;
&#xD;
Falling You - exploring the beauty of voice and sound&#xD;
http://www.fallingyou.com</description>
      <pubDate>Sat, 14 Jan 2006 01:12:02 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#1f5cce1b-845e-4b3b-ac89-c22aabc58702</guid>
      <dc:creator>John Michael</dc:creator>
      <dc:date>2006-01-14T01:12:02Z</dc:date>
    </item>
    <item>
      <title>Trouble with strcat</title>
      <link>http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#fd62a256-a7da-4795-a74a-f9680712de4a</link>
      <description>I am writing a program in C but I am getting an error when it compiles that doesn't make any sense:&#xD;
Warning: passing argument 1 of 'strcat' makes pointer from integer without a cast.&#xD;
&#xD;
The relevant bits of code are:&#xD;
The variables:&#xD;
char  da   = 'A';&#xD;
char  db   = 'C';&#xD;
char  dc   = 'G';&#xD;
char  dd   = 'T';&#xD;
char  dna1 [100000];&#xD;
&#xD;
Where the error appears:&#xD;
if(random == 1)&#xD;
       strcat(da, dna1);&#xD;
else if (random == 2)&#xD;
       strcat(db, dna1);&#xD;
else if (random == 3)&#xD;
       strcat(dc, dna1);&#xD;
else&#xD;
       strcat(dd, dna1);&#xD;
&#xD;
It doesn't like strcat for some reason.  Both are chars, so it *should* work as far as I can tell.&#xD;
&#xD;
Anyone have any suggestions to a c newbie?&#xD;
&#xD;
Thanks!</description>
      <pubDate>Sat, 14 Jan 2006 00:34:37 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/12556948-c28e-48bf-a528-83b26f286c5b#fd62a256-a7da-4795-a74a-f9680712de4a</guid>
      <dc:creator>WTL</dc:creator>
      <dc:date>2006-01-14T00:34:37Z</dc:date>
    </item>
  </channel>
</rss>



