i am having this code for read a txt file. which i want to read 3 numbers each line, first two is two nodes and the second is the length of two nodes, for example 1 2 10 which means from nodes 1 to nodes 2 the length is 10. Please help me find out which part is wrong for my code?
#include <iostream>
#include <fstream>
using namespace std;

int main()
{


int c[100][100];
int p, q, len;
ifstream fin;
fin.open("filename.txt")
for(int i=1; i<=3; ++i)
for(int j=1; j<=3; ++j)
c[i][j] = 99999;

for(int i=1; i<=3; ++i)
{
fin >> p >> q >> len;
c[p][q] = len;
c[q][p] = len;
}
fin.close();

}

just try to compile it and check it is working or not.

Sponsored Links