You see what? Please provide context when posting a followup.
Suggested links:
http://cfaj.freeshell.org/google/
http://www.caliburn.nl/topposting.html
http://clc-wiki.net/wiki/Introduction_to_comp.lang.c
It would also be helpful if you would use standard capitalization; by
making it easier it is for us to read what you write, you can help us
to help you.
now why can't i write to:
char *s = "hello";
s[3]='\0'; <-causes the error
printf("%s", s);
What exactly do you mean by "causes the error"? The problem in this
case happens to be fairly obvious, but in general it's very important
to tell us *what* went wrong. You might also want to read
<
http://www.catb.org/~esr/faqs/smart-questions.html>.
The problem is that you're trying to modify a string literal. A
string literal such as "hello" specifies a statically allocated array
of characters. Any attempt to modify this array, as you've done
above, invokes undefined behavior, which means it may or may not work,
and the compiler isn't obligated to tell you that you've made a
mistake. Don't do that.
If you want a string you can modify, you can declare it like this:
char s[] = "hello";
Here you declare an array (which you can modify), and the string
literal specifies how the array is initialized. This is in contrast
to your original declaration, in which the *pointer* is initialized to
point to the (possibly unmodifiable) array associated with the string
literal itself.
basically, the bigger picture what i'm trying to is extract words from
a string with / as its delimiter , such as
char * s = "dirA/dirB";
by finding the index of the / , set s[4]='\0', so now i have two
strings: s is "dirA" and (s+4) is "dirB"
You might want to look at the standard strtok() function. It has some
serious problems (it modifies the string you're splitting, it can't be
used on more than one string at a time, and its treatment of
consecutive delimiters is questionable), but it may be just what
you're looking for.