when i use char or char*, visual studio 2012(11) only couts last character such as:
#include <iostream>
#include <string>
int main(){
using namespace std;
char chName = 'Alex';
cout<<chName;
}
It displays only “x”. it is correct is i use
string strName = "Alex"
but in those function which have parameter as a char, string can not be passed on as argument. in this case, VS compiler says that strings cant be converted into int.
also tell me what is difference between char and char*.
I am a PHP developer and C++ is so confusing. Please help me.
is a multicharacter literal and it is implementation defined.
instead of this, you should use
or
Difference between char and char*
In
char ch;ch is a char variable which can store a single ascii character, whereaschar *ch;is a pointer to char which can store address of a char variable.Difference between char and String
see this SO post.