I wrote some functions that will output the x and y intercepts of a circle. Now I need to send the output to a text file and I also need to add some text to the output file. Thanks in advance for your help.
#include<stdio.h>
int main()
{
int x, y;
// ... your code that finds the intercepts here
FILE* file = fopen("filename.txt", "wb"); // open a file for writing
char output[255]; // a buffer to hold the output text
sprintf(output, "X intercept: %d\nY Intercept: %d", x, y); // fill the buffer with some information
fputs(output, file); // write that buffer into the file
fclose(file); // close the file handle
return 0;
}
#include <fstream>
int main()
{
double x;
double y;
// calculate values for x and y here
std::ofstream ofs("filename.txt");
ofs << "x = " << x << std::endl;
ofs << "y = " << y << std::endl;
}