C??????ββ?????
?????????? ???????[ 2016/10/17 11:13:38 ] ???????????? ???
????????漰C/C++?????????????????
//??????δ????????????????????
#include <stdio.h>
#include <stdlib.h>
#define HELLO_STRING "Hello World"
static void mem_alloc(char *p?? int size){
p = (char*)malloc(size);
}
int main(int argc?? char const *argv[])
{
char *ptr = NULL;
mem_alloc(ptr?? HELLO_STRING);
strcpy(ptr?? HELLO_STRING);
printf("String is %s
"??ptr );
return 0;
}
?????????????????? δ?????????δ??????sizeof??strlen??????
????????????????????????????βν???????????????
????char *ptr = NULL;
????mem_alloc(ptr?? HELLO_STRING);
????strcpy(ptr?? HELLO_STRING);
????printf("String is %s
"??ptr );
???????????mem_alloc()??????????ptr???????NULL??????????????????????????????????????????????????? ?δ??? ??
????????????????βδ????????????????????????????????????
?????????????????
#include <stdio.h>
void fun(int *p){
int b=100;
p=&b;
}
int main(int argc?? char const *argv[])
{
int a=10;
int *q=NULL;
q=&a;
printf("%d
"?? *q);
fun(q);
printf("%d
"?? *q);
return 0;
}
???????н???10 10
????q?????????и?????q??????????????fun()??fun()?е?p??????q?????????fun()?????????p?????100????????q???????????κα仯??
#include <stdio.h>
void fun(int *p){
*p=100;
}
int main(int argc?? char const *argv[])
{
int a=10;
int *q=NULL;
q=&a;
printf("%d
"?? *q);
fun(&q);
printf("%d
"?? *q);
return 0;
}
???????н???10 100???????????q?????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11