I am trying to get the firts part of my program running and this is what I have so far:
Code:
#include <iostream>
using namespace std;
const int Size = 20;
int main ()
{
char FirstNumber [Size];
char SecondNumber [Size];
int Idx;
int Idx2;
int Num1 [Size];
int Num2 [Size];
//input
cout<<"Enter the first number, less than 20 digits long, please : ";
int Count = 0;
while (Count < Size && cin>>FirstNumber [Count])
{
Count++;
}
for ( Idx = 0; Idx < Count ; Idx++)
{
cin>>FirstNumber [Idx];
int Num1 [Idx] = FirstNumber [Idx] - '0'; //changing char to int
}
cout<<"Enter your second number, less than 20 digits long, please";
int Count2 = 0;
while (Count2 < Size && cin>>FirstNumber [Count2])
{
Count2++;
}
for (Idx2 = 0; Idx2 < Count2 ; Idx2++)
{
cin>>SecondNumber [Idx2];
int Num2 [Idx2] = SecondNumber [Idx2] - '0';
}
return 0;
}
So I enter the first number but then nothing happens, it doesn't go on to ask for the second number. I am trying to count how many sinlge digits are entered and then trying to read in those digits into the array one by one. Also when I try to convert the characters to integers I get an error. Any one have nay ideas?