'i' does not name a type.

Can someone help me find the problem in my code ?

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
  #include <iostream>
#include <fstream>

using namespace std;
void skaityti(int A[], int B[], double C[], int D[], int E[], int & n);
int didv(double C[], int n);
const int Cmax = 100;

int main()
{
    ifstream fd("duom.txt");
    ofstream fr("rez.txt");
    int men[Cmax],diena[Cmax],brvk[Cmax],raud[Cmax],n;
    double mase[Cmax];
    skaityti(men,diena,mase,brvk,raud,n);
    didv(mase,n);
}
void skaityti(int A[], int B[], double C[], int D[], int E[], int & n)
{
    ifstream fd("duom.txt");
    fd >> n;
    for (int i = 0; i < n; i++){
        fd >> A[i] >> B[i] >> C[i] >> D[i] >> E[i];
    }
    fd.close();
}
int didv(double C[], int n)
{
    double max = C[0];
    int maxind = 0;
    for (int i = 1; i < n; i++)
        if (C[i] > max) {
            max = C[i];
            maxind = i;
    }
    return maxind;
}

Last edited on
Builds fine for me. Are you sure you posted the right code?
Yes, this is the right one. It says error: 'i' does not name a type. First time i'm having such a problem.
I'm sure it says more than. For one thing, it will be telling you what line that error occurs on.
I fixed it somehow by deleting a few extra lines under my code. I have no idea what those lines had to do with my code.
Topic archived. No new replies allowed.