How can i write an array to file using C++?? i need to write the whole array at once, meaing that the writing function should take a pointer to the array.
And the array is holding floating numbers..
What's that fuction name that will satisfy that? How can i do it??
Thank you..

Here this code should help.

You need to do it manually, send the function to do the saving the pointer the the array, and the number of elements in the array.

#include <fstream.h>

void saveArray(float* array, int length);

int main()
    float floatArray[] = { 15.25, 15.2516, 84.168, 84356};
    saveArray(floatArray, 4);

    return 0;

void saveArray(float* array, int length)
    ofstream output("output.txt");

    for(int i=0;i<length;i++)


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.