Results 1 to 5 of 5

Thread: Unable to login using fstream

  1. #1
    Join Date
    Nov 2009
    Posts
    131

    Unable to login using fstream

    Hello friends,
    I am working on project where I am using C++ plus as front end. In this project using fstream I have created one login program. In this program I save my all data in a text file. When I open that file I see something like:
    username:password:level
    Whenever I tried to retrieve the data from this file I get following error.
    ifstream login(FileName);
    login >> username >> password >> level; I will not able to get proper result. I get following result.
    username = username:password:level
    password = null
    level = null
    I don't know why I Unable to login using fstream. Please help me.
    Last edited by Juany; 01-02-2010 at 07:36 PM.

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Unable to login using fstream

    From your information it seems that you are getting problem due to ">>" operator. If your all data is in string then you can use following code.

    Code:
     // It is used to take user name
    getline(login,userid,':'); 
    // It is used to take password
    getline(login,passwords,':');
    // It is used to check level 
    getline(login,level,':');
    After this you will not get any problem.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Unable to login using fstream

    You have to use following code in your program to fix this problem. You have to first import that file into your program and then you have to retrieve all information like Username, Password and level. Just go through following code.

    Code:
    ifstream login("filename");
    login.open("filename");
    getline(login,username,':');
    getline(login,password,':');
    getline(login,level,':');
    login.close();

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Unable to login using fstream

    It seems that you are using old C++ STL libraries and that's why you are getting such type of problem. In this case you have to use more advanced libraries to fix this problem. You have to use following library in starting to fix this problem.

    #include <iostream>
    #include <fstream>
    using namespace std;

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Unable to login using fstream

    It seems that you are using wrong path for retrieving information from that file. You may be using "C:\data.txt" this path to access information and that's why you are getting such type of problem. In this case you have top use following path to fix this problem.
    "C: emp.txt"
    Just use this path in your program to access username and password information.

Similar Threads

  1. Unable to login in UBISHOP
    By KumaraVel in forum Technology & Internet
    Replies: 6
    Last Post: 16-09-2011, 09:56 PM
  2. Unable to login in my ICQ account?
    By Tana$ya in forum Technology & Internet
    Replies: 7
    Last Post: 18-06-2011, 09:22 PM
  3. Unable to Login in APP HUB
    By Bikendi in forum Technology & Internet
    Replies: 4
    Last Post: 19-04-2011, 10:44 PM
  4. DHT unable to login in uTorrent 2.0
    By Sirens in forum Technology & Internet
    Replies: 6
    Last Post: 26-06-2010, 10:06 AM
  5. Unable to login with Firefox
    By Floyd in forum Technology & Internet
    Replies: 3
    Last Post: 10-03-2009, 07:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,136,171.66188 seconds with 17 queries