作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下函数应该加密最多 10 个字符的字符串。
#include <stdio.h>
#include <string.h>
void crypt(char*);
int main()
{
//one random message of up to 10 chars and function call.
char str[7] = "george";
crypt(str);
printf("%s",str);
}
//this function crypt's the initial string's message.
void crypt(char str[])
{
int i=0;
while ((i<=10)&&(str[i]!='\0'))
{
if (str[i]<=119) {str[i] = str[i] + 3;}
else if (str[i]==120) {str[i]='a';}
else if (str[i]==121) {str[i]='b';}
else {str[i]='c';}
i++;
}
}
}
相反,DevC++ 给了我这个错误:
***In function 'int main':
[Error] invalid conversion from 'char*' to 'char' [-fpermissive]
[Error] initializing argument 1 of 'void crypt(char)' [-fpermissive]***
如有任何帮助,我们将不胜感激。提前致谢。
最佳答案
你可以尝试这样的事情
void crypt(char* str) // to conform with your prototype
{
for (int i = 0; str[i] != '\0' && i < 10; ++i)
{
if (str[i]<=119) { str[i] = str[i] + 3; }
else if (str[i]==120) { str[i]='a'; }
else if (str[i]==121) { str[i]='b'; }
else { str[i]='c'; }
}
}
关于c - 函数调用中的连线错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21065797/
我正在寻找一种将选项文件传递给wiredep的简单方法,它允许我在angular之上设置jquery,到目前为止,它是通过依赖项工作的,因此它在底部设置jquery。 我作为选项传递: var opt
我是一名优秀的程序员,十分优秀!