#include <stdio.h>
char message[100] = {"hello world"};
void *test(void)
{
char *p = message;
printf("%s\n",p);
return p;
}
int main()
{
char *charp;
printf("-----subfunction area--------\n");
test();
printf("------main function area-------");
charp = test();
printf("%s\n", charp);
return 0;
#include <stdio.h>
int main()
{
const char *arg = "hell world!";
char const *p = "new world!";
char *const q = "old world!";
printf("%c\\n", *arg);
arg++;
printf("%c\\n", *arg);
*arg = 'X';
printf("%c\\n", *arg);
printf("%c\\n", *p);
p++;
printf("%c\\n", *p);
printf("%c\\n", *q);
q++;
printf("%c\\n", *q);
return 0;
}
beyes@linux-beyes:~/C> gcc -g const.c -o const.exe
const.c: In function ‘main’:
const.c:11: error: assignment of read-only location ‘*arg’
const.c:19: error: increment of read-only variable ‘q’
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |