![]() |
| ||
| changing the expected row of text file i using seekp() function to change the pwd, but it can only change the first row of peter's pwd. Wat i wanted was to change only the pwd that belongs to only mary if marry has login. How can do it? need some advice!!! this is wat my text file looks like: peter:pwd:abcd ps: i try to match the username to my text file but it still only change the first row. |
| ||
| Re: changing the expected row of text file You have to delete the file then rewrite the file with the new password. |
| ||
| Re: changing the expected row of text file if the file is deleted then the rest of the data will be gone also. i wanted to know how can i get to the row that below to marry? |
| ||
| Re: changing the expected row of text file >if the file is deleted then the rest of the data will be gone also So save the necessary info before you delete it and write it to another file. |
| ||
| Re: changing the expected row of text file thanks iamthwee!!! ur help is not i seeking for. As i m using seekg() function to get the column position of which i wanted and change the data. but i want to know how to get to the my text file marry row? |
| ||
| Re: changing the expected row of text file jamthwee is right -- in order to change something in a text file you have to rewrite the entire file, making whatever changes you want while writing the file. Calling seekg() does nothing to help you with that. If the current password is "abc" and the new password is "abcdefg" then you can't stuff 7 characters into the filespace for 3 characters. There are at least two ways to do it: 1) read each line of the file into an array of lines, make in-memory change to marry's password, truncate the original file to 0 length, then finally rewrite all the lines back to the file. 2) create a new temp file -- then do this pseudocode open original file for read [edit]If the new password is exactly the same length as the password in the file, then open the file for read/write, seek to the position of the old password then just write in the new password.[/edit] |
| ||
| Re: changing the expected row of text file >but i want to know how to get to the my text file marry row? Pretty simple read in the file line by line. Split each line by the : mark. Use that to find the user. |
| ||
| Re: changing the expected row of text file Is there a way to get to the row that belong to marry? |
| ||
| Re: changing the expected row of text file Not directly, you have to read the file one line at a time until you find marry's row. When working with files with variable-length rows there is no easy way to do it. |
| ||
| Re: changing the expected row of text file ok then can i cout the entire row that belong to marry? |
| All times are GMT -4. The time now is 1:52 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC