- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- void funcpp(char ** p)
- {
- char *tmp;
- tmp = malloc(sizeof(char) * 10);
- sprintf(tmp,"%.08d",1);
- *p = tmp;
- }
- void funcValue(char p)
- {
- printf("funcValue=%c\\n",p);
- p = 'M';
- }
- void funcp(char *p)
- {
- p = "mary";
- printf("in funcp=%s\\n",p);
- }
- int main(int argc,char *argv[])
- {
- /* int nc = 1;
- nc++;
- char strnc[8];
- sprintf(strnc,"%08d",nc);
- printf("the formatted ncstr is %s\\n",strnc);
- */
- char *p = "hunter";
- funcValue(*p);
- printf("after funcValue %s\\n",p);
- funcp(p);
- printf("after funcp %s\\n",p);
- funcpp(&p);
- printf("after funcpp %s\\n",p);
- free(p);
- }
- output:
- funcValue=h
- after funcValue hunter
- in funcp=mary
- after funcp hunter
- after funcpp 00000001
- //该片段来自于http://www.codesnippet.cn/detail/260320149136.html
来源: http://www.codesnippet.cn/detail/260320149136.html