the uploaded is a assignment and i want to solve this task using the library fstream and using the tellp ,seekg other functions also can some body help me in that how to use all these things..!!I WROTE A FUNCTION ALSO BUT IT IS NOT READING THE FILE??? THE FUNCTION IS.--

#include "CSimpleList.h"



CSimpleList::CSimpleList(){};

void CSimpleList::loadFromFile(string filename)
{  
  if(filename == "")
  {
      cout<<"Enter valid filename"<<endl;
    }

  string line;
  ifstream myfile("Phonebook.txt",ios::in); 

  if (myfile.is_open())
  {
      cout<<"file is opened"<<endl;
    while ( myfile.good() )
    {
        cout<<"readin the line"<<endl;
      getline (myfile,line);
      cout << line << endl;
    }
    myfile.close();
  }
 else cout << "Unable to open file"; 


}

  int CSimpleList::size()
{
    return m_list.size();  
}


  int CSimpleList::getNumber(int pos)
{   


    //trim(m_data,";");
    int i=m_pos;
    //i++;
    int number;
    string temp="";
    //temp=m_data.substr(i);
    while(i!=m_data.size())
    {
        temp+=m_data[i];
        i++;
    }
    number=atoi(temp.c_str()); //convert string to integer
    return number;
}



 */

Are you running this from inside the IDE?
If so, can you give it the full path to the file and see whhat happens?

the file that the program has to read has to be in a .txt format. you should also try declaring a variable using ofstream(used to put stuff in a text file), ifstream(used to output stuff thats in a text file), and fstream(works for both but has issues).

the uploaded is a assignment and i want to solve this task using the library fstream and using the tellp ,seekg other functions also can some body help me in that how to use all these things..!!I WROTE A FUNCTION ALSO BUT IT IS NOT READING THE FILE??? THE FUNCTION IS.--

http://www.daniweb.com/software-development/cpp/threads/6542

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.