Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 来自ifstream的文本带有\开始时为0\0\0_C#_C++_String_Ifstream - Fatal编程技术网

C# 来自ifstream的文本带有\开始时为0\0\0

C# 来自ifstream的文本带有\开始时为0\0\0,c#,c++,string,ifstream,C#,C++,String,Ifstream,下面是我如何获得文本的: switch(lsel) { case 0: luafile = "lua/example.lua"; break; case 1: luafile = "lua/example2.lua"; break; } ifstream f(luafile); f >> noskipws; //don't want to skip spaces ! vector<unsi

下面是我如何获得文本的:

switch(lsel) {
    case 0:
        luafile = "lua/example.lua";
        break;
    case 1:
        luafile = "lua/example2.lua";
        break;
    }
ifstream f(luafile);
f >> noskipws;  //don't want to skip spaces !
vector<unsigned char> v(
    (istream_iterator<unsigned char>(f))
    , (istream_iterator<unsigned char>()));
LBytes lexing = LBytes(bytes, 2);
lexing += lselect;
lexing += LBytes(v.data(), v.size());
//f.close();
return lexing;
并放入RichTextBox

private void confListBox_SelectedIndexChanged(object sender, EventArgs e) {
    if (confListBox.SelectedIndex < 10) {
        string one = Core.lua[confListBox.SelectedIndex];
        this.luaTextBox.Text = one;
        }
而文本将是


\0\0\0\0
资料来自何处?

似乎您在文本前添加了一些资料,这些资料来自与文件不同的来源:

LBytes lexing = LBytes(bytes, 2);
lexing += lselect;
lexing += LBytes(v.data(), v.size());

我怀疑是前两行造成了零。

ah肯定是
Array.Copy(Core.ncon.ArrayRead,2,valx,0,Core.nco.ArrayReadSize-2-sizeof(int))中的错误
必须是
Array.Copy(Core.ncon.ArrayRead,2+sizeof(int),valx,0,Core.ncon.ArrayReadSize-2-sizeof(int))
"\0\0\0\0io.write(\"Please enter your name: \")\n-- name = io.read() -- read input from user\nname = \"someone\"\nprint (\"Hi \" .. name .. \", enjoy hacking with Lu"
LBytes lexing = LBytes(bytes, 2);
lexing += lselect;
lexing += LBytes(v.data(), v.size());