I'm getting the 2 warnings on line 65 and 67. Not sure of what exactly the error meanings are telling me. If someone has an explanation for me, I would appreciate an explanation. I'm self taught and very new. I included the whole source code below. If any other improvements are standing out, just give me an idea of what else you see could be improved. The D5 file has over 12,018,??? lines in it with 5 integers per line. I guess "pointers" would be more efficient?, but like I said, I'm very new, and I haven't a clue on how to use them yet. Plus "pointers" kinda scare me, the memory leaks, I just don't understand them. Anyway, here are what the warnings say.
Warning #1:
/Users/Brian/Documents/CPP-Projects/MyWorkspace/Filter_Testing/main.cpp:65:93: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
int draw_del5 = std::adjacent_difference( d5[a].begin(), d5[a].end(), d5[a].begin() );
Warning #2:
C:/Users/Brian/Documents/CPP-Projects/MyWorkspace/Filter_Testing/main.cpp:67:89: error: no match for 'operator==' (operand types are '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'int')
if ( std::adjacent_difference ( d5[b].begin(), d5[b].end(), d5[b].begin() ) == draw_del5)
====2 errors, 87 warnings==== The 87 warnings are basically derived from the 2 errors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <cstdlib>
#include <numeric>
#include <iomanip>
#include <chrono>
#include <iterator>
using namespace std;
int main ()
{
std::ifstream infile;
std::string line;
std::string d5file;
std::cout << "Enter the Name of your D5 File : ";
std::cin >> d5file;
infile.open(d5file);
if (!infile) {
std::cerr << "Problem opening file" << std::endl;
return 1;
}
int number_of_lines = 0;
while (std::getline(infile, line))
++number_of_lines;
std::cout << "Your D5 File has " << number_of_lines << " lines" << std::endl;
infile.clear();
infile.seekg(0);
std::cout << "\n";
std::cout << "Loading D5 File.....\n";
std::vector<std::vector<int>> d5(number_of_lines,std::vector<int>(5));
while ( !infile.eof()) {
for ( int i = 0; i < number_of_lines; ++i) {
for ( int j = 0; j < 5; ++j) {
infile >> d5 [i][j];
}
}
}
infile.close();
int draws_reporting;
std::cout << "How Many Draws to plot the reports? ";
std::cin >> draws_reporting;
long long unsigned int layer_rep_start {1};
int a {0};
int line_number {1};
while ( line_number <= draws_reporting) {
long long unsigned int b {layer_rep_start};
int sum_counter {0};
int draw_sum = std::accumulate ( d5[a].begin ( ), d5[a].end ( ), 0);
for ( ; b < d5.size () ; ++b, ++sum_counter ){
if ( std::accumulate ( d5[b].begin ( ), d5[b].end ( ), 0) == draw_sum)
break;
}
// int b {layer_rep_start}; Got "redeclaration of int b" error! Hope b resets after ++b in each for loop.
int del5_counter {0};
int draw_del5 = std::adjacent_difference( d5[a].begin(), d5[a].end(), d5[a].begin() );
for ( ; b < d5.size() ; ++b, ++ del5_counter ){
if ( std::adjacent_difference ( d5[b].begin(), d5[b].end(), d5[b].begin() ) == draw_del5)
break;
}
std::cout << line_number << " " << sum_counter << " " << del5_counter << endl;
++layer_rep_start;
++ a;
++ line_number;
}
return 0;
}
|