#include <stdio.h>

void make_ppm_header(int wd, int ht);
void create_image(int wd, int ht, unsigned int r, unsigned int g, unsigned int b);

int main()
{	/*width and height of the image*/
	int width, height;

	/*Holds the RGB - red, green, and blue values*/
	unsigned int red, green, blue;


	printf("Enter the width and height you wish your image to be: ");
	scanf("%d%d", &width, &height);

	printf("Enter the values for red, green, and blue:  ")
	scanf("%d%d%d", &red, &green, &blue);
	
	create_image(width, height, red, green, blue);

	return 0;

}

/*This function will create the ppm header for the file
 *notice there is no space between 255 and the newline character*/
void make_ppm_header(int wd, int ht)
{
	fprintf(stdout, "P6\n");
	fprintf(stdout, "%d %d 255\n", wd, ht);
}

/*This function will first call make_ppm_header, 
 *next it will create the RGB value for each pixel*/
void create_image(int wd, int ht, unsigned int r, 
	              unsigned int g, unsigned int b)
{
	int count = 0;
	make_ppm_header(wd, ht);
	/*You can use a for loop or a while loop to iterate through
	 *each pixel in the Width * Height image.*/

	while(count < (wd * ht))
	{
		fprintf(stdout, "%c%c%c", r, g, b);
		count++;
	}
}

