我想编写一个程序来验证字符串是否为回文。但是当我尝试传递strings[0]
给removeSpaces
将删除空格的函数时出现错误。
为什么会comflicting types
出现“错误”?怎么了?
整个程序代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char * removeSpaces(char *); // prototype
int main()
{
char *strings[2]; // created array of pointers
strings[0] = strdup("a man a plan a canal panama");
printf("%s\n", strings[0]);
strings[1] = removeSpaces(strings[0]);
printf("%s\n", strings[0]);
/* (in future) it will display "amanaplanacanalpanama" */
free(strings[0]);
return 0;
}
char * removeSpaces(char * str[0]) // an ERROR occurs here
{
/* some code */
return -1; // in case of fault
}