您当前的位置: 首页 > 

对方正在debug

暂无认证

  • 5浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

c指针与字符串

对方正在debug 发布时间:2021-09-14 00:44:22 ,浏览量:5

#include
using namespace std;
#define ll long long 
const int maxn = 110;

void test1() {
	char buf[12];
//	[Error] invalid conversion from 'const char*' to 'char' [-fpermissive]
//	buf[4] = "hell";
}
void test2() {
	char buf[4];
	strcpy(buf, "hell");
	printf("%s\n", buf);// hell
}
void test3() {
	char buf[4];
	printf("strlen(\"len\"): %d\n", strlen("len"));
	memcpy(buf, "hello", strlen("len"));
	printf("%s\n", buf);// hell
}
void test4() {
	char *p;
//	[Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
//	p = "abc";
	
}
void test5() {
	char s[] = "a3n9X*";
	char *p = s;
	
	printf("%c\n", *p + 4);// e
}
int main() {
//	test2();
//	test3();
	test5();
	
} 
关注
打赏
1664895754
查看更多评论
立即登录/注册

微信扫码登录

0.1456s