#include <iostream>
usingnamespace std;
float* int_to_float(int* data, int size) {
float* ydata = newfloat[*size];
for (int x = 0; x < size; x++) {
ydata[x] = data[x];
}
return ydata;
}
int main() {
int data, size;
cout << "Enter Data: ";
cin >> data;
cout << "Enter Size: ";
cin >> size;
cout << int_to_float(&data, size); /* here when I do (data, size) it makes error so I put & before data but is this why it prints address for size? */
delete ydata;
return 0;
}
Is that what you're trying to do? Make an array of the same numbers? So if the user enters 5 for data and 3 for size, you end up with an array: {5 5 5} ?
wow thanks
float* returned_array = int_to_float(data, size);
// this returned means data that has been returned from function return ydata; this right?