文件'safe-read.c'包含lib'config.h',这个文件放在哪里?
我在libs中发现了许多带有此名称的文件,但我不知道它是正确的.
UPDATE
我的文件是:
...
#include <safe-read.h>
#include <safe-read.c>
...
Run Code Online (Sandbox Code Playgroud)
在文件safe-read.c中有这个包含块
#include <config.h> //line 19
/* Specification. */
#ifdef SAFE_WRITE
# include "safe-write.h"
#else
# include "safe-read.h"
#endif
/* Get ssize_t. */
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#ifdef EINTR
# define IS_EINTR(x) ((x) == EINTR)
#else
# define IS_EINTR(x) 0
#endif
#include <limits.h>
#ifdef SAFE_WRITE
# define safe_rw safe_write
# define rw write
#else
# define safe_rw safe_read
# define rw read
# undef const
# define …Run Code Online (Sandbox Code Playgroud) 我想要计算文件中的字符(在各种字符集中)并且我使用函数'mbtowc'来检测字符.我无法弄清楚为什么字符和结果值不同.这是我的例子:
char buf[BUFFER_SIZE + MB_LEN_MAX];
int fd = open ("chinese_test", O_RDONLY);
unsigned int bytes, chars;
int bytes_read;
bytes = chars = 0;
while((bytes_read = read(fd, buf, BUFFER_SIZE)) > 0) {
wchar_t wc_buf[BUFFER_SIZE], *wcp;
char *p;
int n = 0;
bytes += bytes_read;
p = buf;
wcp = wc_buf;
while((n = mbtowc(wcp, p, MB_LEN_MAX)) > 0) {
p += n;
wcp++;
chars++;
}
}
printf("chars: %d\tbytes: %d\n", chars, bytes);
Run Code Online (Sandbox Code Playgroud)
我用一些带有GB2312字符的文本测试函数,但字符和字节的值太大了.
我的测试返回 - >字符:4638 | bytes:17473但'wc'linux命令返回:chars:16770 | 字节:17473 …