小白的白 @ 2017-03-28 00:18:33
#include<stdio.h>
#include<string.h>
int main()
{
char str[15],*p;
p=str;
gets(str);
if(str[0]=='-'){//如果是负数,指针移动一位,提前输出符号
p++;
printf("-");
}
strrev(p);//反转字符串
while(*p=='0')//找到第一个非零数
p++;
if(*p=='0')//如果最后一位是零则指针后退一位
p--;
puts(p);
return 0;
}
by OSYj @ 2017-03-31 20:01:46
source.cpp: 在函数‘int main()’中:
source.cpp:7:5: 警告:‘char* gets(char*)’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(str);
^ source.cpp:7:13: 警告:‘char* gets(char*)’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(str);
^ source.cpp:12:13: 错误:‘strrev’在此作用域中尚未声明
strrev(p);//反转字符串
^
编译错误
by OSYj @ 2017-04-06 20:31:18
source.cpp: 在函数‘int main()’中:
source.cpp:7:5: 警告:‘char* gets(char*)’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(str);
^ source.cpp:7:13: 警告:‘char* gets(char*)’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(str);
^ source.cpp:12:13: 错误:‘strrev’在此作用域中尚未声明
strrev(p);//反转字符串
^
编译错误