小编Suc*_*hal的帖子

我糊涂了!C++中的Char,Char*或String

当我使用char或char*时,visual studio 2012(11)只会播放最后一个字符,例如:

#include <iostream>
#include <string>
int main(){
 using namespace std;
 char chName = 'Alex'; 
 cout<<chName;
}
Run Code Online (Sandbox Code Playgroud)

它只显示"x".它是正确的是我使用 string strName = "Alex" 但在那些有参数作为char的函数中,字符串不能作为参数传递.在这种情况下,VS编译器说字符串不能转换为int.还告诉我char和char*之间有什么区别.我是一名PHP开发人员,C++非常混乱.请帮我.

c++ c-strings

5
推荐指数
2
解决办法
3621
查看次数

标签 统计

c++ ×1

c-strings ×1