首先,我是新来的,所以请原谅我在问题中犯的任何错误。 :(
我的作业要求我打印以输入学生 ID,然后删除该特定学生的信息并更新文本文件。我有 4 个文本文件,其中包含不同学生的信息,如何为每个文件做到这一点?
我尝试遵循许多教程,但没有任何效果,有一些示例代码
预期输出是“已删除的学生记录”,但它没有出现..
最佳答案
请更具体地说明您提到的 4 个 txt 文件中学生数据的存储方式 您可以做的一般事情是
1.take the student_id from user
2.loop through the txt file //you can use while loop
read txt file txt_file_student_data_id
copy the text file data to temporary file if student_id!=txt_file_student_data_id
//use string comparison or integer depending upon id
3.delete txt file
4.rename temporary file to txt file
5.do the same for remaining file
关于c - 有没有办法通过输入学生 ID 来删除文本文件中的记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56520205/