In case your interested in how the code looks now here it is:
Code:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
void work_with_string_int_to_find_condition(string array_element_five, string array[][5], int previous_element_one, int current_element_one, int second_counter)
{
cout << array_element_five << " " << array[second_counter][4] << " " << previous_element_one << " " << current_element_one << endl;
}
int main()
{
string array[100][5];
string read_array[5];
string array_element_two = "";
string array_element_five = "";
int first_counter = 0;
int second_counter = 0;
int third_counter = 0;
int previous_element_one = 0;
int current_element_one = 0;
ifstream read_record_file("record.txt");
while(read_record_file >> read_array[0] >> read_array[1] >> read_array[2] >> read_array[3] >> read_array[4])
{
array[first_counter][0] = read_array[0];
array[first_counter][1] = read_array[1];
array[first_counter][2] = read_array[2];
array[first_counter][3] = read_array[3];
array[first_counter][4] = read_array[4];
first_counter++;
}
read_record_file.close();
for(int i = 0; i < first_counter; i++)
{
cout << array[second_counter][0] << " " << array[second_counter][1] << " " << array[second_counter][2] << " " << array[second_counter][3] << " " << array[second_counter][4] << endl;
second_counter++;
third_counter++;
if(third_counter == 1)
{
array_element_two = array[second_counter][1];
previous_element_one = stoi(array_element_two);
array_element_five = array[second_counter][4];
}
else if(third_counter == 2)
{
if((array_element_five != ".") && (array[second_counter][4] != ".") && (array_element_two != ".") && (array[second_counter][1] != "."))
{
array_element_two = array[second_counter][1];
current_element_one = stoi(array_element_two);
work_with_string_int_to_find_condition(array_element_five, array, previous_element_one, current_element_one, second_counter);
array_element_two = array[second_counter][1];
previous_element_one = stoi(array_element_two);
}
array_element_five = array[second_counter][4];
}
else if(third_counter == 3)
{
if((array_element_five != ".") && (array[second_counter][4] != ".") && (array_element_two != ".") && (array[second_counter][1] != "."))
{
array_element_two = array[second_counter][1];
current_element_one = stoi(array_element_two);
work_with_string_int_to_find_condition(array_element_five, array, previous_element_one, current_element_one, second_counter);
array_element_two = array[second_counter][1];
previous_element_one = stoi(array_element_two);
}
array_element_five = array[second_counter][4];
third_counter = 2;
}
}
}
Here's the record.txt file:
Code:
testing 1 F 349 red
testing 2 F 349 green
one 3 g_sharp 415 blue
two 1 C 261 red
three 2 A 440 green
testing 3 F 349 blue
testing 1 F 349 red
one 2 g_sharp 415 green
two 3 C 261 blue
testing 1 F 349 red
testing 2 F 349 green
one 3 g_sharp 415 blue
two 1 C 261 red
. . . . .
And here's the output which is correct:
Code:
testing 1 F 349 red
testing 2 F 349 green
green blue 2 3
one 3 g_sharp 415 blue
blue red 3 1
two 1 C 261 red
red green 1 2
three 2 A 440 green
green blue 2 3
testing 3 F 349 blue
blue red 3 1
testing 1 F 349 red
red green 1 2
one 2 g_sharp 415 green
green blue 2 3
two 3 C 261 blue
blue red 3 1
testing 1 F 349 red
red green 1 2
testing 2 F 349 green
green blue 2 3
one 3 g_sharp 415 blue
blue red 3 1
two 1 C 261 red
. . . . .
Process returned 0 (0x0) execution time : 0.016 s
Press any key to continue.
You know, coding is tiring for me, because I have to think.