Code format tags work like this: [code] {your code here} [/code]. Please edit your post and fix it.
Why are you doing so many nested loops if you just need to read from a file?
Simply do something like:
1 2 3 4 5
int a, b, c, d;
while (myfile >> a >> b >> c >> d) // loops as long as it is able to fill the 4x numbers with valid information
{
cout << "contents: " << a << b << c << d << '\n';
}
Oh you want to split the digits of an individual int?
This is a good learning experience, my hint is that % 10 (modulus) will extract the right-most digit, and / 10 (integer division) will remove the right-most digit.
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Example program
#include <iostream>
int main()
{
usingnamespace std;
int number = 123;
int m = number % 10;
int d = number / 10;
cout << m << '\n'; // 3
cout << d << '\n'; // 12
cout << d % 10 << '\n'; // 2
}
I would work on writing a separate function that prints the separated digits of an input number. (It will need to use a loop).
e.g.
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
void print_digits(int n)
{
// fill in here
}
int main()
{
print_digits(1234);
}
Online 12 the variables "i", "j", "k" and "l" are defined. Then used as the for loop counters. Does that not mean when you read something into the variables it changes how the for loop works?