Read in integers from file, find max; RGB to CMYK Conversion HELP

Hello, I have to write a c++ program that converts RGB values to CMYK values. I'm new to this and I am trying to get the hang of it.
This is what I have to do in particular, without the use of arrays:

1. Write a function that reads an RGB value(from a .txt file) and rejects invalid values. An invalid value would be any R G or B pixel below 0, or above 255.

2. Write a function max(a, b, c) that returns the maximum of its three parameters.

3. Write a function RGBtoCMYK(r, g, b, c, m, y, k) that receives RGB values as input parameters, and returns CMYK values as reference parameters.

The data looks like:
50 50 50 // each line serves as one RGB value
0 0 0
255 255 255
0 100 100
200 200 0
150 0 150
300 0 0
1 1 1
0 0 245

I understand how to do each of these separately, but i can't seem to put it all together. The text file has 3 numbers on each line(i.e. 50 0 250). This serves as one RGB value.

My main issue with this program is that I need to read in r g and b pixels on a line, calculate the maximum of those, and then do the same for the rest of the lines in the txt file. After that, I have to send the r,g,b pixels and max for each line to the last function and convert the values to CMYK(which I can do once I get the first part done)

My readRGB function looks something like:
1
2
3
4
5
6
7
8
9
  void readRGB(float& r,float& g, float& b)
{
    while(!infile.eof()&&infile>> r>>g>>b) {
        if(r>=0&&r<=255){

        cout<< r<<" "<<g<<" "<<b<<" "<<endl;}
        else
            ;
    }


I've tested this and it prints every three numbers on a separate line. I need to somehow find the largest number of each line with the max function I am supposed make.
I'm thinking it should look like this, but that would only return one max value for the entire file:
1
2
3
4
5
6
7
8
9
10
11
12
13
int max(float a,float b, float c)
{
    readRGB(a,b,c);
    int maximum=-1;
    if(a>maximum)
        maximum=a;
    if(b>a)
        maximum=b;
    if(c>b&&c>a)
        maximum=b;
    if(a==b==c)
        maximum=a;
    return maximum;



I've been stuck on this for a while and all help would be appreciated. Thank you.
P.S. If this is too vague, i will gladly clarify.
Topic archived. No new replies allowed.