Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
required help in for read txt file in c++ and java
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to make .h file in c++ Vuhelper 0 3,620 11-05-2011, 05:20 PM
Last Post: Vuhelper
  In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from C:\Do sana.pari 2 3,553 11-02-2011, 03:02 AM
Last Post: baig66
  how can i read the last letter of a input file? 2011 Vuhelper 0 1,834 09-12-2011, 10:24 PM
Last Post: Vuhelper
  Overloaded >> operator not reading more than first line from data file in c++ 2011 Vuhelper 0 915 07-23-2011, 05:38 PM
Last Post: Vuhelper
  Read data from file into arrays in c++ 2011 Vuhelper 0 916 07-20-2011, 10:58 PM
Last Post: Vuhelper
  Creating File Associations in c++ 2011 Vuhelper 0 934 07-20-2011, 10:51 PM
Last Post: Vuhelper
  how to implement java's MAC libraries for a file 2011 Vuhelper 0 1,941 06-14-2011, 09:18 PM
Last Post: Vuhelper
  The use of Function templates in C++ and C, java, php 2011 Xpert 0 1,949 05-29-2011, 07:36 PM
Last Post: Xpert
  How to Write a function factorial in C++ and java and php 2011 Xpert 1 2,539 05-12-2011, 10:02 PM
Last Post: dawoodasad17
  Problem with adding Symbols inside the C++ and java language 2011 Xpert 0 1,823 05-12-2011, 09:10 PM
Last Post: Xpert

Forum Jump:


Users browsing this thread: 1 Guest(s)