简体   繁体   中英

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.

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

EDIT: Changing the strlen to sizeof merely changed the error to "Buffer size too small" instead.

See documentation on 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 .

Change it to be sizeof(fullName) and your error should disappear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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