A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Hello @Sid Kraft ,
Thanks for your question.
Your file is empty because:
- Use out instead of cout to write to the file.
- Change I <= INOW to I < INOW to avoid accessing element 20 in a 20-element array.
- There are some minor syntax mistakes::
-
#include <fstream> - int I = 0;
-
You can refer to the following code example:
#include <iostream>
#include <fstream>
int main() {
float PLOTX[20] = {0};
float PLOTY[20] = {0};
float PLOTZ[20] = {0};
int INOW = 20;
int I = 0;
std::ofstream out("C:/PlotData.txt");
do {
out << PLOTX[I] << ' ' << PLOTY[I] << ' ' << PLOTZ[I] << '\n';
++I;
} while (I < INOW);
out.close();
return 0;
}
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback. Thank you.