简体   繁体   English

C++ 存储到文件

[英]C++ Storing to file

So I need some help to understand why.所以我需要一些帮助来理解为什么。 The problem is that on the console registries with path are displayed normally, but when I want to store them in the file, the names and the paths becomes some sort of code.问题是在控制台注册表上正常显示路径,但是当我想将它们存储在文件中时,名称和路径变成了某种代码。

Hope you guys will help me.希望大家帮帮我。 Thanks!谢谢!

PS The main task is to make the console message to be the same and in the txt file. PS 主要任务是让控制台消息和txt文件里的一样。

You are currently using wcout to print out to console.您当前正在使用wcout打印到控制台。 This means that the string is wide char which is different from char (wchar takes 2 bytes and char takes only 1 byte).这意味着字符串是与char不同的wide char (wchar 占用 2 个字节,char 只占用 1 个字节)。

However, outfile is obviously not a unicode file stream.但是, outfile显然不是 unicode 文件流。

To fix this, try to make outfile be a wfstream or wofstream .要解决此问题,请尝试使outfile成为wfstreamwofstream

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM