我已经检查了很多编程语言(Java,Erlang,python等)但我发现C/C++很难学习.仅仅因为我认为它有时候不合理;
EX1:
#include <iostream>
int main() {
int ar1 = {1,2,3};
int *p1 = ar1;
char *msg = "message";
std::cout << "addr: " << p1 << std::endl ;//prints the array address
std::cout << "value: " << *p1 << std::endl ;//prints the first element
std::cout << "addr: " << msg << std::endl ;//prints "message" , wtf why not the addr?how can i get its address?
std::cout << "value: " << *msg << std::endl ;//prints the first character
}
Run Code Online (Sandbox Code Playgroud)
EX2:
#include <iostream> …Run Code Online (Sandbox Code Playgroud)