Jun 30, 2011 at 11:10pm UTC
Use int. char is for characters, as the name already says.
Jun 30, 2011 at 11:59pm UTC
You can skip the C-style cast (the
(int )
) on line 4. << does work with char*s, though I'd suggest that you use strings instead. :)
1 2 3 4 5 6 7
#include <iostream>
#include <string>
int main(){
std::string a="12345" ;
std::cout<<a<<std::endl;
std::cin.sync(), std::cin.ignore();
return 0;}
12345
-Albatross
Last edited on Jul 1, 2011 at 12:00am UTC
Jul 1, 2011 at 8:58am UTC
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
using namespace std;
int main()
{
char a[5]("12345" );
cout<<a<<endl;
cin.get(); cin.get();
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
using namespace std;
int main()
{
int a = 1234;
cout<<a<<endl;
cin.get(); cin.get();
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
using namespace std;
int main()
{
int a;
cout<<Enter number: ";
cin>>a;
cin.get(); cin.get();
return 0;
}
Last edited on Jul 1, 2011 at 9:00am UTC
Jul 1, 2011 at 9:19am UTC
Janlan.I want to convert char to int and convert while doesn't change result.
My char value:12345
My char to int convert value:12345
ok???
Jul 1, 2011 at 9:50am UTC
It is impossible to have a char value of '12345', unless you mean a vector of chars.
Jul 1, 2011 at 10:12pm UTC
It can make with TextField or another data input-output tools.
Last edited on Jul 1, 2011 at 10:12pm UTC
Jul 2, 2011 at 3:02am UTC
char data type contains only 1bytes(Enlish Charaters are all 1 bytes.). So, you should use array list or pointer or String class.
Jul 2, 2011 at 8:39pm UTC
Thank u Janlan.
Last edited on Jul 2, 2011 at 8:43pm UTC