我一直在尝试让这段代码*char[]
使用 ROT13 加密来加密指针数组。几个问题:
- 该程序无法编译。错误是:“文本”:数组初始化需要花括号。
- ROT13 似乎无法正常工作。它保存 ASCII 代码的数值而不是其等效字母。
这是我的代码:
void rot13(int numlines, char * text[]){
//printf("%s\n", text);
//char encrypted[length(text)];
for (int i=0; text[i]>='\0'; i++){
if (*text[i]>='A' && *text[i]<='Z'){
*text[i]=(((*text[i]-'A')+13)%26 + 'A');
}else if(*text[i]>='a' && *text[i]<='z'){
*text[i]=(((*text[i]-'a')+13)%26 + 'a');
}
}
printf ("%d\n ",*text);
}
int main(){
char text1[]="parliament";
char * text[]=&text1;
rot13(10, text);
}