如何删除字符“从C ++中的文本文件开始? [英] How do I remove the character "" from the beginning of a text file in C++?

查看:685
本文介绍了如何删除字符“从C ++中的文本文件开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图读取一个文本文件,对于每个单词,我将它们放入二叉搜索树的节点。但是,第一个字符总是读作+第一个字。例如,如果我的第一个单词是This,那么插入我的节点的第一个单词是我一直在寻找一个解决方案的论坛,有一个帖子问同样的问题在Java,但没有人在C ++中解决了。有人会帮助我解决它吗?谢谢。

I'm trying to read a text file, and for each word, I will put them into a node of a binary search tree. However, the first character is always read as " + first word". For example, if my first word is "This", then the first word that is inserted into my node is "This". I've been searching the forum for a solution to fix it, there was one post asking the same problem in Java, but no one has addressed it in C++. Would anyone help me to fix it ? Thank you.

我来到一个简单的解决方案。我在记事本中打开文件,并将其保存为ANSI。之后,文件正在读取并正确传递到二叉搜索树中

I came to the a simple solution. I opened the file in Notepad, and saved it as ANSI. After that, the file is reading and passing correctly into the binary search tree

推荐答案

这是UTF-8的 BOM

您需要将文件读为UTF-8。如果您不需要Unicode,只需使用前127个ASCII码点,然后将文件保存为ASCII或UTF-8,而不使用BOM

You need to read the file as UTF-8. If you don't need Unicode and just use the first 127 ASCII code points then save the file as ASCII or UTF-8 without BOM

这篇关于如何删除字符“从C ++中的文本文件开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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