User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,628
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 865
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: changing the expected row of text file

  #11  
Apr 23rd, 2008
Huh?
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
Reply With Quote  
Join Date: Nov 2007
Posts: 40
Reputation: picass0 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
picass0 picass0 is offline Offline
Light Poster

Re: changing the expected row of text file

  #12  
Apr 23rd, 2008
i have this file which is like this:
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
Reply With Quote  
Join Date: Nov 2007
Posts: 40
Reputation: picass0 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
picass0 picass0 is offline Offline
Light Poster

Re: changing the expected row of text file

  #13  
Apr 23rd, 2008
i have this file which is like this:
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
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,628
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 865
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: changing the expected row of text file

  #14  
Apr 23rd, 2008
>>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: 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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 8:39 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC