I am trying to store the RGB values of a color into a struct named RGBTriple which is made up of three unsigned char Red, Green, Blue. I am reading in those values from a file and then parsing the string and assigning the correct value with the correct variable. Whenever I am reading in the unsigned char values the program is only reading in the first number even if the value is 255. After the width, height, and color are read in. I am creating a picture object. I do not have any trouble reading in the width or height.
Here is my RGBTriple
struct RGBTriple
{
unsigned char Blue;
unsigned char Green;
unsigned char Red;
RGBTriple();
RGBTriple(unsigned char Blue, unsigned char Green, unsigned char Red);
};
and here is my main:
int pictureWidth, pictureHeight;
RGBTriple pictureColor;
string line;
getline(input, line);
istringstream iss(line);
iss >> pictureWidth;
iss >> pictureHeight;
iss >> pictureColor.Red;
iss >> pictureColor.Green;
iss >> pictureColor.Blue;
Picture newPicture(pictureWidth, pictureHeight, pictureColor);
Here is an example of my input: the first line is what is read in for the Picture Object.
200 200 255 255 255
Point 66 66 000 000 000
Line 100 150 50 50 255 000 000
Rectangle 50 25 55 33 000 000 000
RTriangle 10 80 50 30 000 000 000
Star 29 29 15 000 000 000
Diamond 120 120 20 000 000 000
Polygon 150 0 175 0 175 50 150 25 X X 000 000 000
Circle 40 89 26 000 000 000