Этот код отказывается выводить данные в файл любого типа (txt или ppm — это цель здесь).
Цель кода — вывести результат в файл ppm и нарисовать простые фигуры, без ничего слишком сложного. В коде нет видимых ошибок, он работает нормально, но ничего не выводится; Я думаю, что это может быть проблема с записью в файловую часть кода, но подтверждения этому пока не нашел.
Код: Выделить всё
#include
#include
#include
#include
using namespace std;
const int WIDTH = 300;
const int HEIGHT = 200;
struct Pixel {
unsigned char red;
unsigned char green;
unsigned char blue;
};
/*
A function that will write the specified data for the
shapes in the image to the specified file
@param image - the array that will be written to by this function
@param height - the height of the image
@param fileName - the name of the file that will utilize the array
@return bool - true if the file opens, false if the file fails to open
*/
bool writeImage(Pixel image[][WIDTH], int height, const string fileName) {
ofstream imageFile;
imageFile.open(fileName);
if (!imageFile) // checks if the file successfully opened
{
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79380280/what-is-the-reason-for-my-code-not-outputting-to-a-file[/url]