linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* strtok, bus error
@ 2009-02-17  2:52 Fundu
  2009-02-17  3:57 ` Bryan Christ
  2009-02-17  4:04 ` ben
  0 siblings, 2 replies; 6+ messages in thread
From: Fundu @ 2009-02-17  2:52 UTC (permalink / raw)
  To: linux-c-programming

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!


      

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-02-17 21:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-17  2:52 strtok, bus error Fundu
2009-02-17  3:57 ` 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

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).