【发布时间】:2016-04-19 19:29:28
【问题描述】:
您好,我在尝试编译代码时遇到错误。
int main()
{
char string_buffer[20], string_buffer1[20];//which is going to be copied into and reversed.
printf("Enter the string to check if it is a palindrome\n");
scanf("%20s", string_buffer);
strcpy(string_buffer1,string_buffer);//copying string_buffer into string_buffer1
strrev(string_buffer1);//reverse string_buffer1
if (strcmp(string_buffer,string_buffer1) == 0){//check to see if they are the same
printf("Palindrome.\n");
}else{
printf("Not a palindrome.\n");
}
return 0;
}
当我尝试编译时,我收到此警告和错误。
palindrome.c:12:2: warning: implicit declaration of function 'strrev' is invalid
in C99 [-Wimplicit-function-declaration]
strrev(string_buffer1);//reverse string_buffer1
^
1 warning generated.
/tmp/palindrome-1efe10.o: In function `main':
palindrome.c:(.text+0x68): undefined reference to `strrev'
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)
【问题讨论】:
-
我不认为
strrev在 linux 中可用。 -
我相信这可以被认为是重复的。 stackoverflow.com/questions/8534274/…
标签: c