简体   繁体   English

表达式:(L“字符串不为null终止”&&0)

[英]Expression: (L “String is not null terminated” & & 0)

I am fiddling around with mailslots and now I've run into a problem. 我在摆弄邮筒,现在遇到了问题。 Whenever I try to run, I get the error message in the title, but I don't know how I should go about fixing it. 每当我尝试运行时,都会在标题中显示错误消息,但是我不知道应该如何解决。 What I am trying to do is "fixing" the full path of the mailslot, but it seems to not like the strcat_s-part. 我正在尝试做的是“固定”邮槽的完整路径,但似乎不喜欢strcat_s-part。

HANDLE mailslotCreate (char *name) {
    char fullName[50] = "\\\\.\\mailslot\\";
    strcat_s(fullName, strlen(fullName), name);
    return CreateMailslot(fullName, 0, TIME_OUT, NULL);
}

Imgur link to error Imgur链接到错误

EDIT: Changing the strlen to sizeof merely changed the error to "Buffer size too small" instead. 编辑:将strlen更改为sizeof仅将错误更改为“ Buffer size too small”。

See documentation on strcat_s . 请参阅有关strcat_s的文档。 It says that second parameter should be the size of destination buffer. 它说第二个参数应该是目标缓冲区的大小。 As you pass strlen(fullName) , there is no room for terminating \\0 . 当您传递strlen(fullName) ,没有终止\\0

Change it to be sizeof(fullName) and your error should disappear. 将其更改为sizeof(fullName) ,您的错误应消失。

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

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