On 8/9/06, ravikohli2412 <[EMAIL PROTECTED]> wrote:
> #include<stdio.h>
> void main()
int main() (void main() is deprecated)
> {
> char a[]="abc";
> char *b="good";
> b[0]='a';--THis line gives error
> strcpy(b,"fff");--This line gives error
return 0;
> }
>
> Can anybody explain me the procedure how the variables 'a' and 'b' get
> stored and initialized in memory. Also please let me know the cause of
> the error.
b points to immutable data -- you can't change that data. You can
change what b points to, however. If you want to be able to change the
data b points to, you will need to dynamically allocate the memory
using malloc, or use a statically allocated array.
--
Brett McCoy: Programmer by Day, Guitarist by Night
http://www.alhazred.com
http://www.cassandrasyndrome.com
http://www.revelmoon.com
To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/