This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin (december 2003 version) and strcat


On Apr 19 23:49, Martin Johansen wrote:
> Hi.
> 
> I am experiencing problems using strcat and strncat.
> 
> For some reason, these functions do not appent a zero.

$ cat > str.c << EOF
? #include <stdio.h>
? #include <string.h>
? 
? int
? main ()
? {
?   char c1[100], c2[100];
? 
?   memset (c1, 0xff, 100);
?   memset (c2, 0x77, 100);
? 
?   c1[0] = '\0';
?   c2[0] = '\0';
? 
?   strcat (c1, "1234567890");
?   strncat (c2, "1234567890", 5);
? 
?   printf ("c1: <%s>\n", c1);
?   printf ("c2: <%s>\n", c2);
? 
?   return 0;
? }
? EOF
$ make str
gcc     str.c   -o str
$ ./str
c1: <1234567890>
c2: <12345>


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Co-Project Leader          mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]