Compile Error
/in/foo.c:3:6: warning: return type of 'main' is not 'int' [-Wmain] void main(){ ^~~~ /in/foo.c: In function 'main': /in/foo.c:5:9: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[50]' [-Wformat=] scanf("%s",&s); ^ /in/foo.c:11:1: error: expected declaration or statement at end of input } ^ /in/foo.c:4:13: warning: variable 'd' set but not used [-Wunused-but-set-variable] char s[max],d[max]; ^
代码
#include<stdio.h>
#define max 50
void main(){
char s[max],d[max];
scanf("%s",&s);
int i = 0;
while(s[i]!='\0'){
int r = ((s[i] + 5) - 'a')%26;
d[i] = 'a' + r - 1;
i++;
}