Static Cast (from Array) trouble

Hello,

I have a program in progress to dump the contents of my array (by subscript) into individual int's that I will use to create a Check. However, my static cast is still returning the ASCII values after casting. Can someone tell me what I did wrong or point me in the right direction

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main()
{	
int hunds, tens, ones;
const int size = 7;
char amountin[size];



string mname, cdate;
cout << "Enter the date of the check:";
getline(cin, cdate);
	

cout << "Enter name, a blank, last name: ";
getline(cin,mname);
	
cout << "Enter the Amount as XXX.XX, Enter leading and trailing 0's: ";
cin >> (amountin);

for(int i=0; i <(amountin[i]); i++)
{
	hunds= amountin[0];
	tens= amountin[1];
	ones= amountin[2];
}
cout << "hunds: " <<static_cast<int> (hunds) << endl;
cout << "tens: " << static_cast<int> (tens) << endl;
cout << "ones: " << static_cast<int> (ones) << endl;




string oneplace[11] =  {" ","one", "two", "three", "four", "five", "six","seven", "eight", "nine"} ;
string tenplace[11] = {" ","ten","twenty","thirty","fourty","fifty", "sixty", "seventy", "eighty", "ninety"};
string hundred[3] = {" ","hundred"};







//------------------------------------SIMULATED CHECK-------------------------------------------------------------------
cout << endl;
cout << setw(50) <<  cdate << endl;
cout << endl;
cout << endl;
cout << "pay to the order of: " << mname << setw(15) << "$ " << amountin;
cout << endl;

cout << endl;
cout << endl;

system("pause");
return 0;




}

static_cast doesn't convert ASCII values to normal digits, and at any rate you're casting from an int to an int. I'm afraid you'll have to do that conversion yourself. :/

Hint: '0' may be of some use.

-Albatross
Last edited on
Thank you Albatross. I didn't even really think about that I was casting a data type...to the same data type! I did eventually nail this down! Thank you for the help.
Topic archived. No new replies allowed.