+ 1

How I can invok a any line that I want from the File?

Suppose if I have file and this file contains information for more than one person how I can invok information about specific person Like 1 2 3 4 I need to call number 3without the Other?

9th Mar 2022, 8:10 PM
ABUBAKAR ALHOMIDY
ABUBAKAR ALHOMIDY - avatar
4 ответов
+ 3
ABUBAKAR ALHOMIDY , let's assume that the information in each line is like: 1; tom; peters ... 23;... to get the respective information about the person with the id of 23 we need the following steps open the file for reading iterate through the lines of the file and check if the line starts with 23 if yes, use the complete line to process it close the file if you want to modify some data and save the changes, we need to do some more effort happy coding!
9th Mar 2022, 8:21 PM
Lothar
Lothar - avatar
+ 3
ABUBAKAR ALHOMIDY , to modify data that are stored in a file, the procedure is: open the file for reading read all the lines of the file and store them in a data structure line by line search and modify the related data write the complete (modified) data structure to a new file (line by line) with a temporary filename delete the old file and rename the new file to the original name close file you should also look for a library, that can do this procedure for you *** be aware that trying to do this procedures can lead to a file corruption in case of coding errors. so do all your tries only with data that are duplicated ***
10th Mar 2022, 11:02 AM
Lothar
Lothar - avatar
+ 1
How I can modify the file without delete previous information?
9th Mar 2022, 8:34 PM
ABUBAKAR ALHOMIDY
ABUBAKAR ALHOMIDY - avatar