当我尝试编译codeblocks给定的代码。它给了我的预期(在加密方法的签名文本之前编译错误谁能告诉我为什么会这样编译错误C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void encrypt(string text , int key)
{
for(int i = 0, n = strlen(text); i < n ; i ++)
{
if((text[i] >= 'A' && text[i] <='Z') || (text[i] >= 'a' && text[i] <='z'))
printf("%c", (text[i] + (key % 26)));
else
printf("%c",text[i]);
}
}
int main()
{
printf("Enter any String: \n");
string text;
scanf("%s", &text);
int x;
printf("Enter Key: \n",&x);
encrypt(text,x);
return 0;
}
'字符串不是C中的东西... –
@OliCharlesworth我已经包含字符串库之前我的代码,那么为什么它给我一个错误? –
因为'字符串'不是C中的东西。 http://en.cppreference.com/w/c/string/byte获得''标题的内容。 –