converting an integar into an array?

This is a discussion on converting an integar into an array? within the C++ Programming forums, part of the General Programming Boards category; I am trying to come up with a program that converts a number
say:-
1359 and the program turns it ...

int numArray[5]={0} with a value instead of
int numArray[]={0} it works as i would expect but
I dont know how big i want the array to be when the
program starts is this where i would use Dynamic Memory Allocation?

as long as numToConvert is always 4 digits long your code looks and works fine. But what happens if you have input other than 4 digits long? If you use the style suggested by minesweeper you can do the same thing with an integer having any number of digits, the only problem being the numbers are retrieved in reverse order, but that's easily overcome, and your program becomes much more generalized.

I wrote the above funtions for previous programs and they have been very usefull.

The functions getlength and getmember are used to typecast ints into arrays (or vectors). getlength returns the length of an int as if it were an array of ints less than 10. getmember returns the member specified of your virtual array of ints less than 10 (or any int . I used vectors in my example because I can't stand how unflexable plain arrays are.

To answer your question.... if you can use arrays, then use them. They are much faster than vectors. Vectors are used alot when you need an array whose size changes all the time. It makes it easier to control.