相关疑难解决方法(0)

C:char指针和数组之间的差异

考虑:

char amessage[] = "now is the time";
char *pmessage = "now is the time";
Run Code Online (Sandbox Code Playgroud)

我从C编程语言第2版​​中读到,上述两个陈述没有做同样的事情.

我一直认为数组是一种操作指针来存储一些数据的便捷方式,但显然情况并非如此...... C中数组和指针之间的"非平凡"差异是什么?

c arrays pointers

135
推荐指数
5
解决办法
5万
查看次数

从char*复制到char arrray

我的角色指针指向一些记忆说"Hello world",我想将它与其他指针进行比较,后来想做strcpy.我认为可以做char*

char *A ="hello"
char *B ="";

strcmp(A,B); // this compares correctly because B points to diff string
strcpy(B,A); // will this statment copies the string alone or both will point to same memory
Run Code Online (Sandbox Code Playgroud)

c visual-c++

-3
推荐指数
1
解决办法
873
查看次数

标签 统计

c ×2

arrays ×1

pointers ×1

visual-c++ ×1