资源简介
Q1077615.zip C++读文件创建链表问题 https://ask.csdn.net/questions/1077615

代码片段和文件信息
// Q1077615.cpp : Defines the entry point for the console application.
//
#include “stdafx.h“
#include
#include
#include
#include
using namespace std;
struct student
{
unsigned long id;
string name;
float score;
student *next; //下一个结点的指针
};
int main()
{
student head = {-1““0};
head.next = NULL;
student * p = &head;
FILE * fp = fopen(“Score.txt“ “r+“);
while (true)
{
unsigned long id;
char name[100];
float score;
if (fscanf(fp “%ld%[^]%f“ &id name &score) == EOF) break;
p->next = new student;
p = p->next;
p->next = NULL;
p->id = id;
p->name = name;
p->score = score;
}
int n;
while (1)
{
cin >> n;
if (n == 0) break;
p = head.next;
while (p)
{
if (p->id == n)
{
cout << p->name << “ “ << p->score << endl;
break;
}
p = p->next;
}
if (!p || p->id != n)
cout << “no record!“ << endl;
}
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-05-24 13:36 Q1077615\Debug\
文件 51712 2020-05-24 13:32 Q1077615\Debug\Q1077615.exe
文件 891 2020-05-24 13:15 Q1077615\Q1077615.sln
文件 12288 2020-05-24 13:34 Q1077615\Q1077615.suo
目录 0 2020-05-24 13:26 Q1077615\Q1077615\
目录 0 2020-05-24 13:36 Q1077615\Q1077615\Debug\
文件 996 2020-05-24 13:32 Q1077615\Q1077615\Q1077615.cpp
文件 4402 2020-05-24 13:26 Q1077615\Q1077615\Q1077615.vcxproj
文件 1366 2020-05-24 13:26 Q1077615\Q1077615\Q1077615.vcxproj.filters
文件 143 2020-05-24 13:15 Q1077615\Q1077615\Q1077615.vcxproj.user
文件 1722 2020-05-24 13:15 Q1077615\Q1077615\ReadMe.txt
文件 143 2020-05-24 13:19 Q1077615\Q1077615\Score.txt
文件 295 2020-05-24 13:15 Q1077615\Q1077615\stdafx.cpp
文件 320 2020-05-24 13:15 Q1077615\Q1077615\stdafx.h
文件 314 2020-05-24 13:15 Q1077615\Q1077615\targetver.h
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
评论
共有 条评论