Reading from file input problem !!

i face a problem when i read input from a file, so what is the solution of this problem ?
the input format is --->
4 4
1 2 3 4
5 6 7 8
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
 
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;

int main()
{
    fstream file("r.txt");

    long long int a1;
    long long int k=0;
    long long int k1=0;
    long long int k2=0;
    long long int n;
    long long int c;
     long long int *a;
     long long int *b;

    while (file >> a1 )
    {

       if(k==0)
       {
           n = a1;

           a = new long long int(n);
           b = new long long int(n);

       }
       else if(k==1)
       {
           c = a1;


       }
       else if( k < (n+2) )//////6
        {

            if(a1>c)
            {
                a[k1] = c;



            }
            else
            {
                a[k1] = a1;



            }
            k1++;

        }
        else if( k >= (n+2) )
        {

            b[k2] = a1;
            k2++;


        }
        k++;
    }

    file.close();
    return 0;
}
Last edited on
mahmoud2592 wrote:
i face a problem when i read input from a file
Could you explain what this problem is?
When i run this code the windows send message says " t.exe stopped working " !!?
Last edited on
What kind of problem do you face?
On lines 27 and 28 you create single values instead of arrays of multiple values. Do not confuse () with []
thank you LB
Topic archived. No new replies allowed.