C语言字符串常量和字符串变量和字符指针和读权限和写权限
#include "main.h"
#include <stdio.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <io.h>
int main()
{
//字符指针读一切 写需要权限。。。。
char* pstr = "hello"; // 字符指针 字符常量 这些字符所存储的地址(在常量区)
char buf[] = "hello";
while((*pstr)!='\0') // 这里 *pstr++有问题
{
putchar(*pstr);
pstr++;
putchar('\n');
}
//printf("%c\n",*(buf++)); 数组名是一个常量
//strcpy(pstr,"wro");// 字符串常量是一个地址
pstr = (char*)buf;
while((*pstr)!='\0') // 这里 *pstr++有问题
{
putchar(*pstr);
pstr++;
putchar('\n');
}
strcpy(pstr,"wro");//
//strcpy(pstr,"wro");//
//printf("pstr is %s\n",pstr);
for(;;);
return 0;
}
一勤天下无难事。

浙公网安备 33010602011771号