读取C ++中的文本文件 [英] Read a text file in C++

查看:124
本文介绍了读取C ++中的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题.最近,我在程序中遇到问题.我被困在这个程序中,完全空白.我想知道如何从一个文本文件中读取国家名称,以及从另一文本文件中读取对应的国家名称.

我知道要从一个文本文件中读取内容,但是对此完全空白.有人可以帮忙吗?如果没有,至少要讲述一个深渊的书或参考书.

I have a problem. Recently I got a problem in a program. I am stuck and totally blank in this program. I want to know how to read country name from one text file and name of its corresponding capital from another text file.

I know to read from one text file but totally blank on this. Can anybody help? If not at least tell be about aby book or refference.

推荐答案

写道:​​

我想知道如何从一个文本文件读取contry名称,并从另一个文本文件读取其对应的大写字母的名称.

I want to know how to read contry name from one text file and name of its corresponding capital from another text file.



您将在第二个文件中需要一些信息,该文件将资本链接到国家/地区名称.无论您决定使用哪种名称,它都可以是名称本身,互联网国家/地区名称(英国,br,ch等),IDD代码(44、1、31等).然后,您需要阅读第二个文件,直到与国家/地区名称匹配,然后从找到的数据中选择大写字母.但是,这听起来像是一种效率很低的方法,因此最好将所有数据保存在一个文件中.然后,您可以读取整个文件,并创建名称的字典或数组,并使用某种搜索算法为每个查询选择所需的数据.



You will need some information in the second file that links the capital to the country name. This could be the name itself, the internet country designation (uk, br, ch etc), the IDD code (44, 1, 31 etc), whatever you decide on. You would then need to read the second file until you matched the country designation and select the capital from the data found. However, this sound like a very inefficient method, so it would be better to have all the data in one file. You could then read the entire file and create a dictionary or array of the names and use some searching algorithm to select the required data for each query.


这篇关于读取C ++中的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆