On Wed, May 13, 2009 at 07:48, Michael Alipio <daem0n...@yahoo.com> wrote:
>
>
> I have a c code that looks like this:

And C isn't Perl, perhaps you should ask these sort of questions on a
C list or newsgroup[1]?  Or maybe Stack Overflow[2]?

snip
> However if I replace the stringcopy call arguments with "jude", "anna"
> it compiles fine but i get segmentation fault when running.
snip

Because they are string constants and you are trying to modify the
second string.  You aren't allowed to do that.

snip
> How come printf can accept variable names as well as constant strings such as:
>
> printf ("%s", girl);
>
> and
>
> printf ("Hello World\n");
snip

Because printf only reads from the pointer, it doesn't modify it.

snip
> My stringcopy function only accepts pointers. Shouldn't I be passing pointer 
> to the first element of "anna" when passing the string constant "anna"?? )
snip

You can point to it, but you can't modify it.

1. http://groups.google.com/group/comp.lang.c/topics
2. http://www.stackoverflow.com

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to