From: Patrick Leslie Polzer <leslie.polzer@gmx.net>
To: linux-c-programming@vger.kernel.org
Subject: wcscat problem
Date: Thu, 19 Jan 2006 16:38:00 +0100 [thread overview]
Message-ID: <20060119163800.1b45d984.leslie.polzer@gmx.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
Hello list,
why does wcscat not work like strcat does?
It seems to be leaving the null byte in (C99 source):
#define _GNU_SOURCE
#include <wchar.h>
int main (int ac, char** av)
{
wchar_t* ws = malloc(8);
wcscpy(ws, (wchar_t*)"abc");
wcscat(ws, (wchar_t*)"def");
printf("%s/%s\n", ws, (void*)ws+4); /* "abc/def" [*] */
char* s = malloc(8);
strcpy(s, "abc");
strcat(s, "def");
printf("%s/%s\n", s, s+4); /* "abcdef/ef" */
return 0;
}
Why is this? I also noticed the compiler (gcc4) takes "string steps"
when performing pointer arithmetics with wchar_t pointers, that's why
I needed to cast to void* in line [*].
Leslie
--
gpg --keyserver pgp.mit.edu --recv-keys 0x52D70289
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2006-01-19 15:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-19 15:38 Patrick Leslie Polzer [this message]
2006-01-19 17:57 ` wcscat problem Markus Rechberger
2006-01-19 18:24 ` Patrick Leslie Polzer
2006-01-19 20:52 ` Steve Graegert
2006-01-22 10:30 ` Glynn Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060119163800.1b45d984.leslie.polzer@gmx.net \
--to=leslie.polzer@gmx.net \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).