How to successfully use ‘ostream &fout’ object in a printData function in C++?

Hello, thanks ahead of time for those of you trying to help me. I have a C++ assignment that I have basically done, but there are some tweaks I can't figure out. I have to write a program that generates a series of random numbers and stores them into a C-style array. My teacher made us use a 'bool' function for this, but I've figured that part out. I'm trying to figure out how to use a printData function to [1] print the data to the screen, and [2]print the data to a file called "randomArray.txt".

Here's my function so far:

void printValues(ostream& fout)

{

if(!randomArray(variance, mean, numPoints, x))

{

fout<<randomArray(variance, mean, numPoints, x)<<endl;

fout<<"\n"<<endl;

}

}

NOTE: It also says that my "ostream& fout" object was not declared or can't be used this way etc.

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 1QUIZZ.COM - All rights reserved.