Hi:

I need to create a C++ code that will read a file and then used some of the numbers in the file for some calculations. The file will look like the following:

#IMAGE      NPIX       MEAN  STDDEV    MIN      MAX
 002.jpeg   1048576     1984.     490.1     1870.    65535.
 003.jpeg   1048576     1984.      471.     1875.    65446.
 004.jpeg   1048576     1984.     479.1     1872.    65335.
 005.jpeg   1048576     1984.     473.8     1869.    65535.
 006.jpeg   1048576     1984.     476.3     1869.    65522.

In the file I need to use the numbers underneath the MAX column, and then do some calculations and write the answers onto a new file. Any good ideas ? Thanks

Sorry here is my original code:

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
  ifstream in("objv.sky");
  ofstream out("objv.skyc");
  string image;
  int npix,imageCount;
  double mean, stddev, min, max,forSum,sum;
  getline(in, image); //to skip the header
  cout << "How many images in the list:" << "\n";
  cin >> imageCount;
  while(in >> image >> npix >> mean >> stddev >> min >> max)
  forSum = max;
  sum += forSum;
  double Average,AveragePercent;
  Average = sum/imageCount;
  cout << Average << "\n";
  AveragePercent = Average*0.10;
  cout << AveragePercent << "\n";
  max = max + Average;
  cout << max << "\n";
  //out <<max<<"\n";
}

Hi:

I need to create a C++ code that will read a file and then used some of the numbers in the file for some calculations. The file will look like the following:

#IMAGE      NPIX       MEAN  STDDEV    MIN      MAX
 002.jpeg   1048576     1984.     490.1     1870.    65535.
 003.jpeg   1048576     1984.      471.     1875.    65446.
 004.jpeg   1048576     1984.     479.1     1872.    65335.
 005.jpeg   1048576     1984.     473.8     1869.    65535.
 006.jpeg   1048576     1984.     476.3     1869.    65522.

In the file I need to use the numbers underneath the MAX column, and then do some calculations and write the answers onto a new file. Any good ideas ? Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.