I have to take in a number that is bigger than one digit and put them into an array and give each digit it's own place in an array. then I guess i have to create an array with those same digits to an int. lol how? haha

// Precondition: The user is ready to enter an integer
// Postcondition: The digits of the integer read in are stored
// in reverse order in the array a and the number of digits is 
// stored in sizeA. Array a will have been dynamically allocated
void inputBigInt(IntArrayPtr &a, int& sizeA)
{    
     char* NumberArray;
     NumberArray = new char[MAX_SIZE];
     using namespace std;
     char number;
     cout << "Please enter a number. ";
     cin >> number;
     NumberArray[MAX_SIZE] = number;
     cout << NumberArray[MAX_SIZE];
     cout << endl;
}

Recommended Answers

All 7 Replies

so what exactly is your problem?

the problem is that it's wrong, and I don't know how to take in an array as a char then convert it to int, then make that array equal to the parameter "a".

so you need to have the user enter a integer number and then you are to ouput that back to them in reverse order

how do I put what the user inputs into an array of char?

char input[50];  // makes an character array with 50 elements
cout << "Please enter an integer: ";  //ask for the integer
cin >> input;  // receives the inputed number as a character array

this is a good way to get inputs as strings if you are not allowed to use std::string yet.

Divide the problem into parts:

  1. Declare an array (of type char )where you want to put all those digits in
  2. Get the integer from the user (get it via cin and store it in an integer variable)
  3. Use the itoa function to convert the integer to a c-string (= character array) (Take a look at this for some more information about itoa)

Hope this helps !

I saw that my previous post was just a bit of an overkill :P
(I assume that your Big Integers are stored in a character array): use cin>>[I][U]yourchararray[/U][/I]; >then I guess i have to create an array with those same digits to an int. lol how?
I don't understand this, do you mean that you have to store each digit of the character string into an integer array (where each element is a digit)? ==> Result is memory hog :P

Edit:: I see that NathanOliver had already recommended it to you, so I'm very sorry for this double recommendation :'(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.