local/pointers ? HELP
Date: Mon, 31 May 2004 19:03:17 GMT
why won't be changed the value stored at *s changed, but only local ?
how would it look like to modify it's value in main too ?
void ch_c(char *c)
{
c="world";
printf("inside: %s\n",c);
}
int main(void)
{
char *s;
s=malloc(6);
if(!s)
return 1;
s="hello";
printf("%s\n",s);
ch_c(s);
printf("%s",s);
getch();
return 0;
}
//demonstrative purpose only
--
"It's not right. It's not even wrong."
Relevant Pages
- Re: optional or interface
... Arjen Markus wrote: ... I need to modify the procedure to fit more extensible ... purpose. ... (comp.lang.fortran) - Re: [PATCH] Make hash.h usable in the kernel
... break almost all callers. ... Callers want and need to pass char **, ... and then if they want to modify *end, to convert `end' to plain char *. ... leads to compiler warnings, which lead to even uglier things like the ... (freebsd-net) - problem with charset
... i've some problem to print to screen and save date in mysql if the ... char set: utf-8 unicode ... Modify (hope that you see 2 squares after abad it would ... Modify (hope that you see 2 squares after agog it would be ... (comp.lang.php) - Hyperlink View Only Word Document
... For the purpose of viewing a document that I would like to modify on ... rare occassion using word. ... (comp.databases.ms-access) - =?UTF-8?B?UmU6IHdhcm5pbmc6IGRlcHJlY2F0ZWQgY29udmVyc2lvbiBmcm9tIHM=?= =?UTF-8?B?dHJpbmcgY29uc
... assigning a char * to a char *, ... certainly _can_ go wrong if you try to modify the pointed-to string, ... compiler that you can't modify what foo points to. ... to modify one line, then modify a dozen lines that depend on that, then the hundreds of lines that depend on those, and the single const has infected expressions all over your program. ... (comp.lang.c) |
|