在c++中读取两个文件并进行比较
Reading two Files and comparing in C++
我一直在尝试将用户输入与文件进行比较,我能够打开它。我来展示一下
cout<< "Please Enter your Student ID: ";
cin >> stdID;
cout<< "Please Enter your Course ID: ";
cin >> courseID;
if the courseID is similar to the prerequisite file, eligible, if not, not eligible..
this is the file
course Prereq
cs111 NA
cs112 cs111
cs240 cs112
cs241 cs240
cs214 cs112
cs215 cs112
cs218 cs111
cs310 cs215
cs311 cs112
cs317 cs215
cs318 cs218
cs324 cs240
cs341 cs241
对于像这样简单的东西,我会在一个简单的while
循环中读取输入,使用输入操作符>>
读取两个字符串(并依赖于operator>>
函数返回流的事实,并且流可以在布尔条件下使用)。
然后在循环中将用户输入的字符串与第一个字符串进行比较,如果匹配,则输出第二个字符串(如果不是,例如"NA"
)。
相关文章:
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 两个文件使用彼此的功能-如何解决
- 停止cmake target_link_libraries将插件中静态库的两个对象文件链接到静态库本身
- 我有两个类需要在同一 cpp 文件中相互引用,但第一个类无法识别第二个类类型的对象
- 结构包含在两个头文件中,这两个文件我都不拥有
- Levenshtein 两个文件的距离花费了太多时间
- 如何从文件中读取两个字符串和数字数组,并将它们存储在对象向量中
- 在 txt 文件中显示前两个数字的程序
- 在 c++ 中从文本文件中读取两个十六进制值
- 将两个 cpp 文件合并为一个 cpp 文件
- JNI,使用两个 .so 文件时出错,其中一个文件需要另一个文件
- 两个线程一个使用流 Api,另一个线程创建文件失败并出现错误ERROR_SHARING_VIOLATION
- 比较两个没有一行共同点的大文件
- 在两个.cpp文件之间定义全局类/结构指针
- C++ 如何将两个 makefile 对象目标规则(位于另一个文件夹中)合并到一个目标/规则中?
- 如何在c ++中以一行(水平)打印两个文件的数据?如给定的.这两种形式来自两个不同的文本文件
- 如何在 c++ 中比较两个文本文件
- 包括两个文件 C++ 之间的冲突
- 使用 C++ 读取具有两个连续分隔符的 csv 文件
- 如何检测两个文件条目是否引用与Qt相同的物理文件系统?