作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写 RLE 压缩代码,但 20 行的 itoa 函数出现问题。我该如何解决这个问题?我是 C 语言新手,所以如果您能为我提供部分经过更改的代码,我会很高兴。谢谢你! (抱歉重复,但我无法发表评论)如果您指出我应该插入更改的部分,我将不胜感激!!!!
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void StringRLE(char *pointer) {
char *rle = new char[strlen(pointer)];
int i = 0;
int rleCount = 1;
char *s = pointer + 1, ch[2] = { 0, 0 };
while (*pointer != '\0') {
if (*pointer == *s)
rleCount++;
else{
_itoa_s(rleCount, rle, 10);
ch[0] = *pointer;
strcat(rle, ch);
puts(rle);
rleCount = 1;
}
pointer++;
s++;
i++;
}
}
错误:
Error C2660 Function Does Not Take 3 Arguments ;No instance of overload function
最佳答案
啊,MSDN 功能...好吧,_itoa_s()需要 4 个参数,而您只给了它三个,因此错误表明它不需要 3 个参数。
errno_t _itoa_s(
int value,
char *buffer,
size_t sizeInCharacters,
int radix
);
“没有重载函数实例”告诉您,接受较少参数的 _itoa_s()
函数不超过 1 个。看起来您缺少 radix
或 sizeInCharacters
:
[in] sizeInCharacters
Size of the buffer in single-byte characters or wide characters.
[in] radix
Base of value; which must be in the range 2–36.
关于c - ITOA函数如何在20行内修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22437597/
我是一名优秀的程序员,十分优秀!