you noob. you're banned.
just kidding.
but seriously, you cant have a single array of floats "mixed with" ints.
they're all either one or the other. probably floats. some of the floats just happen to not have any fractional part.
i'm not sure i fully understand your question... you want to print them out exactly as entered? i guess theres a number of ways you could do this.
one way would be to input them as strings, and store them in a string array, then convert them to the appropriate value when needed. ... or, along those lines, a structure where you have the "as enetered" string element, along with a floating point "value" element
is this making sense? is this relevant to your question?
.
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
well, you can use format specifiers
"%.3f" for instance will print up to 3 decimal places but only if they are non-zero digits.
"%.03f" will always print 3 decimal places even if they are zero digits.
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
you cant have a single array of floats "mixed with" ints
You can have an array with different data types, you just need to point to them using void*
example:
void *array[] = {(int*)123, (char*)"Hello"};
cout << (int)array[0]; // prints 123
cout << (char*)array[1]; // prints "Hello"
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
aha. i knew someone was going to call me on that.
:P
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179