•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 396,968 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,984 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 461 | Replies: 13
![]() |
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,628
Reputation:
Rep Power: 36
Solved Threads: 865
•
•
Join Date: Nov 2007
Posts: 40
Reputation:
Rep Power: 1
Solved Threads: 0
i have this file which is like this:
this code able me to change the pwd of 2nd row in my text file. but if the user is peter it will change the pwd acorrding to the row of peter. Is there a way that will know if the user belongs to which row in my text file
marry:1234:id1 peter:4567:id2
wFile.open("passwd.txt",ios::in);
while(!rFile1.eof())
{
getline(rFile1,line);
int row = line.length();
int nxtRow = row + 2;
int found = line.find(":",0);
string u(line,0,found);
int len = u.length();
len = len+1;
int pos = nxtRow+len;
wFile.seekp(pos);
wFile << NewPwd;
//wFile << s;
wFile.close();
}this code able me to change the pwd of 2nd row in my text file. but if the user is peter it will change the pwd acorrding to the row of peter. Is there a way that will know if the user belongs to which row in my text file
•
•
Join Date: Nov 2007
Posts: 40
Reputation:
Rep Power: 1
Solved Threads: 0
i have this file which is like this:
this code able me to change the pwd of 2nd row in my text file. but if the user is peter it will change the pwd acorrding to the row of peter. Is there a way that will check that the user login belongs to which row in my text file
marry:1234:id1 peter:4567:id2
wFile.open("passwd.txt",ios::in);
while(!rFile1.eof())
{
getline(rFile1,line);
int row = line.length();
int nxtRow = row + 2;
int found = line.find(":",0);
string u(line,0,found);
int len = u.length();
len = len+1;
int pos = nxtRow+len;
wFile.seekp(pos);
wFile << NewPwd;
//wFile << s;
wFile.close();
}this code able me to change the pwd of 2nd row in my text file. but if the user is peter it will change the pwd acorrding to the row of peter. Is there a way that will check that the user login belongs to which row in my text file
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,628
Reputation:
Rep Power: 36
Solved Threads: 865
>>Is there a way that will check that the user login belongs to which row in my text file
probably, but it would be os dependent. Get the user's loging name using some system function call and then compare that with the user name on each line of the file. I have no idea how to get the login user name in *nix.
>> string u(line,0,found);
I don't think that works. What you want is this:
probably, but it would be os dependent. Get the user's loging name using some system function call and then compare that with the user name on each line of the file. I have no idea how to get the login user name in *nix.
>> string u(line,0,found);
I don't think that works. What you want is this:
string u = line.substr(0,found); Last edited by Ancient Dragon : Apr 23rd, 2008 at 10:56 am.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
Similar Threads
- Python GUI Problem (Python)
Other Threads in the C++ Forum
- Previous Thread: developers using eclipse IDE for C++ development?
- Next Thread: C++ Complex Matrix Library....



Linear Mode