Re: I'm sorry...



On Mon, 30 Nov 1998 sml13@cornell.edu wrote:

> Good point...BUT, this dies too:
> 
> #include <stdio.h>
> #include <string.h>
> 
> void main() {
>     char* var = "hey you";
> 
>     printf ("%s\n", strtok (var, " "));
> }
> 
> shane

This is no different, the pointer var still points to a constant string.
strtok dereferences the pointer and tries to write to the
dereferenced memory, which is read only.

Manish Vachharajani               Some Haiku: A crash reduces
<mvachhar@vger.rutgers.edu>                   your expensive computer
                                              to a simple stone - Unknown



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]