Error in Reading Text file in VC++ 2008 expression edition

Discussion in 'MFC' started by maria9, Jul 1, 2010.

  1. maria9

    maria9 New Member

    Joined:
    Jul 1, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have writen a C++ program to read 37 text files. The content of the text file is interger numbers. The program was working fine in VC++ 6.0. Now i could not find the free version of VC++ 6.0. I downloaded the free version of VC++ 2008 expression edition and run the same code which was working fine in the older version.

    Now it could not read the input file and there is no error while compiling the program. The name of the text files are b1.txt, b2.txt.... b37.txt.
    Please help me to fix the problem. I have given below the code for your reference.
    Z
    Code:
    #include<process.h>
    #include "stdafx.h"
    #include<new.h>
    #include<conio.h>
    #include<dos.h>
    #include<cstdio>
    #include<cstdlib>
    #include<iostream>
    #include<string>
    #include<fstream>
    using namespace std;
    #include <vector>
    typedef std::vector<int> IntArray1D;
    typedef std::vector<IntArray1D> IntArray2D;
    typedef std::vector<float> FloatArray1D;
    typedef std::vector<FloatArray1D> FloatArray2D;
    using namespace std;
    
    ofstream fout;
    
    std::vector<vector<int> > a;		//variable to access the input matriz
    int m,n;	char outstr[10];
    int nclus;float bz;
    class memory
    {
    		
    	public:
    	void mci_memory();
    			
    };
    void memory::mci_memory()
    {
    	int i;
    	//memory allocation for input values
    	a.resize(m);
    	for ( i =0; i < m; ++i )
      	a[i].resize( n );
    void main()
    {
    	int i,j;
    	char str1[10];			//to read the first input file
    	char str2[10]={".txt"};
    	char str3[15];			//to read the second input file
    	char aq[10];
    	
    	for(who=1;who<=37;who++)
    	{
    		ifstream fin;
    		//Reading of input file one
    		strcpy(str1,"b");
    		strcat(str1,_i64toa(who,aq,10));
    		strcat(str1,str2);
    		fin.open(str1);	//opening of input file and reading the condents
    		fin>>nclus;
    		fin>>m;
    		fin>>n;
    		memo.mci_memory();
    		for(i=0;i<m;i++)
    		{
    			 for(j=0;j<n;j++)
    			 {
    				 fin>>a[i][j];
    				 
    			 }
    			 cout<<endl;
    		}
    		fin.close();
    		
    		 
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice