problem I will read in a second file into the array how d
** problem - I will read in a second file into the array - how do I compare pixel i,r,g in order to combine the two images into 1 image?c++
#include <iostream>
 #include <fstream>
 #include <string>
 #include <math.h>
 #include <stdlib.h>
 #include <stdio.h>
using namespace std;
int heigth = 0; //initialize variables
 int width = 0;
 const int amount = 3;
struct pixelimage // create structure to hold image
 {
     int **tempa;
     int r,g,b;
     int rows, cols;
}image1;// structure type pixelimage
int main()
 {
     const int amount = 3; //variable r b g
     string sentence, filename, mgicnum; //variable to hold comments, magic number and filename
     int width, height, maxCol;
     ifstream inputFile; //open input and output file
     ofstream outputFile;
     outputFile.open(\"Alec001.ppm\", ios:: in | ios::out); //file to open in irfan
     cout << \"enter a file \" << endl; // user prompt
     cin >> filename;
     inputFile.open(\"lec001.ppm\");
     //image2 = inputfile.open(image2.ppm)
     inputFile >> mgicnum;//read in header information
     while ((inputFile>>ws).peek() == \'#\') { inputFile.ignore(4096, \'\ \');}
    inputFile >> height;
     inputFile >> width;
     inputFile >> maxCol;
    cout << mgicnum ;
     cout << height ;
     cout << width ;
     cout << maxCol<<endl;
     outputFile << mgicnum << endl;
     outputFile << sentence << endl;
     outputFile << height << \" \" << width <<endl;
     outputFile << maxCol <<endl;
    int totalsize = (height * width * amount); // total size of array
     int *tempa;
     int i;
     //modified
     tempa = (int *)malloc(sizeof(int)* totalsize);// allocate memory so program does not crash **** error here invalid conversion
      //
             for (i =0; i < totalsize; i++) {
             tempa[i] = 0;
     }
     free(tempa);
   
     for (int i = 0; i < totalsize; i++){
     inputFile >> (image1.r, image1.g, image1.b);//modified
    }
}
Solution
you need to create another variable for struct pixelImage ..
image2
struct pixelimage // create structure to hold image
 {
     int **tempa;
     int r,g,b;
     int rows, cols;
}image1,image2;
now read second image and store it in image2, like you have done for image1
combine image1,image2 store result in image1


