我有这个小程序:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define SIZE 30
void inverti (char s);
int main ()
{
char str[SIZE+1];
gets(str);
printf ("Your imput: ");
puts(str);
invert(*str);
printf ("It works!");
return 0;
}
void invert (char s)
{
int i;
for (i = 0; i < SIZE + 1; i++)
{
if (isupper(str[i]))
str[i] = tolower(str[i]);
else if (islower(str[i]))
str[i] = toupper(str[i]);
}
puts(str);
}
是错误吗?为什么我不能传递str
给我的函数?
In function ‘main’:|
warning: passing argument 1 of ‘inverti’ makes integer from pointer without a cast [enabled by default]|
note: expected ‘char’ but argument is of type ‘char *’|
In function ‘invert’:|
error: ‘str’ undeclared (first use in this function)|
note: each undeclared identifier is reported only once for each function it appears in|
||=== Build finished: 3 errors, 1 warnings ===|