c - 有没有办法通过输入学生 ID 来删除文本文件中的记录?

标签 c visual-studio

首先,我是新来的,所以请原谅我在问题中犯的任何错误。 :(

我的作业要求我打印以输入学生 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/

相关文章:

cssClass 显示为未定义

visual-studio - 如何永久删除 Visual Studio 2005/2008 (ASP.NET, C#) 中的断点

windows - 如何从cl.exe命令行向dll(advapi32.dll)添加静态依赖项?

从图像中复制像素区域

c - e^-x 麦克劳林系列扩展

java - 在运行时编辑变量名称并在运行时创建新变量

c - 退出时是否应该释放分配的内存?

android - 在 Android Xamarin 中的 Activity 开始时更改可绘制的切换按钮

c++ - 为什么我可以更改数组

c++ - 如何在 Visual Studio 中重命名资源?