gcc 里不能使用gets() 和 puts() 函数的解决办法
来源:互联网 发布:儿童电动牙刷价格淘宝 编辑:程序博客网 时间:2024/06/07 11:45
测试代码,删除字符串空格符:
#include<stdio.h>int main(void) { char a[100]; int i = 0, j = 0; printf("input:"); fgets(a, 100, stdin); // gcc中 gets puts函数不能用!! stdin 键盘输入. for (i = 0; * (a + i) != '\0'; i++) { if (*(a + i) != ' ') a[j++] = a[i] ; } a[j] = '\0'; //这里一定要记得加上'\0'结束符,j在最后 //一次执行的时候已经自加1了,所以这里不是a[j+1]='\0'. printf("output:"); fputs(a, stdout); return 0;}
运行:
input:ashf s sjdhf sdfs lj loutput:ashfssjdhfsdfsljl请按任意键继续. . .
用fgets()
、fputs()
函数代替gets()
、puts()
函数。
0 0
- gcc 里不能使用gets() 和 puts() 函数的解决办法
- gcc使用gets和puts报错
- gets和puts函数
- gets()gets_s()puts()函数的使用
- gcc不支持标准c的gets与puts函数
- gcc不支持标准c的gets puts函数
- gets()函数和puts()函数的渊源关系
- 字符串函数的使用...strcat...puts...gets...strlen...strcmp...strcpy
- 字符串处理函数puts()和gets()
- gets()和puts()函数分析
- gets()和puts()函数
- gets()函数puts()函数
- scanf(),printf()和gets(),puts()的区别
- gets()、puts()和fgets()、fputs() 的区别。
- gets()和puts()
- gets和puts
- puts函数的使用
- gets()函数与puts()函数
- Echarts学习记录——设置图表与容器的间隔
- c#中图片与Base64string 的转换
- 计划
- Xcode 8 崩溃 Error Domain=DVTPlugInErrorDomain Code=2
- LeetCode 188. Best Time to Buy and Sell Stock IV
- gcc 里不能使用gets() 和 puts() 函数的解决办法
- 悠然乱弹:开源中国GIT中Java分类下TOP10项目的活动情况分析
- git移除远程仓库某个文件夹
- git上传代码步骤
- 查看python的安装位置及好安装第三方库的位置
- 使用python实现一个简单的学生信息管理系统
- Linux权限管理命令
- MySQL中的锁(表锁、行锁)
- SQL语句常见优化十大案例