From: Fundu <fundu_1999@yahoo.com>
To: linux-c-programming@vger.kernel.org
Subject: strtok, bus error
Date: Mon, 16 Feb 2009 18:52:23 -0800 (PST) [thread overview]
Message-ID: <125035.76273.qm@web63404.mail.re1.yahoo.com> (raw)
i'm trying to do pretty simple replacement using strtok.
but it looks like i have missed some subtle difference between the two following
char src[] = "hello world #";
char *other = "hello world #";
because if i use "char * other" with strtok it fails with bus error but i use src it works, don't understand what's the difference.
here's the code for strtok.
char delims[] = "#";
char *result = NULL;
// this works
result = strtok( src, delims );
// this doesnot work and give a bus error
// result = strtok(other, delims);
while( result != NULL ) {
printf( "result is \"%s\"\n", result );
result = strtok( NULL, delims );
}
what am i missing here ? i thought both way of declaration(mentioned above ) were the same apparently the r not, whats the diff ?
any insight would be appreciated, TIA!
next reply other threads:[~2009-02-17 2:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-17 2:52 Fundu [this message]
2009-02-17 3:57 ` strtok, bus error Bryan Christ
2009-02-17 6:31 ` Fundu
2009-02-17 4:04 ` ben
2009-02-17 20:15 ` Glynn Clements
2009-02-17 21:05 ` ben
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=125035.76273.qm@web63404.mail.re1.yahoo.com \
--to=fundu_1999@yahoo.com \
--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).