Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设您想读入一个可能包含 NULL 的二进制文件。您将如何使用以 NULL 结尾的语言来执行此操作?我猜你只是将它映射到一个字节数组?
如果我们谈论 C(并且相同或类似的论点也适用于 C++),那么这种语言中以零结尾的字符串是一种约定,我不会说“语言以 NULL 结尾”。一些函数 - 喜欢strcpy或strlen将字符串中的空字符视为终止符。其他功能 - 比如fread- 没有。使用文档查看您要使用的函数是否特别处理空字符。
strcpy
strlen
fread