gets不能用
#include<stdio.h>
#include<string.h>
int main()
{
int i=0;
char a[31];
gets(a);
while(a[i]!='#')
{
if(a[i]>='A'&&a[i]<='Z')
a[i]=a[i]-'A'+'a';
else if(a[i]>='a'&&a[i]<='z')
a[i]=a[i]-'a'+'A';
i++;
}
for(i=0;a[i]!='#';i++)
{
printf("%c",a[i]);
}
return 0;
}
a.c: In function ‘main’:
a.c:7:4: warning: ‘gets’ is deprecated [-Wdeprecated-declarations]
gets(a);
^~~~
In file included from /usr/include/stdio.h:862:0,
from a.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:232:1: note: declared here
gets (char *__str)
^~~~
a.c:7:4: warning: ignoring return value of ‘gets’, declared with attribute warn_unused_result [-Wunused-result]
gets(a);
^~~~~~~
/tmp/cc3oWUvp.o: In function `main':
a.c:(.text.startup+0x22): warning: the `gets' function is dangerous and should not be used.