出问题啊,第二个字符串加不上第一个,求修改

[复制链接]
查看11 | 回复3 | 2012-4-16 23:31:02 | 显示全部楼层 |阅读模式
你的程序我帮你修改了两处(见注释),现在运行没问题了。#include#includevoid main( ){ char str1[100],str2[100];
int i,j;printf("请输入字符串1:");gets(str1);printf("请输入字符串2:");gets(str2);i=strlen(str1);for(j=0;j#includevoid main( ){ char str1[100],str2[100];
int i,j;printf("请输入字符串1:");gets(str1);printf("请输入字符串2:");gets(str2);i=st...
回复

使用道具 举报

千问 | 2012-4-16 23:31:02 | 显示全部楼层
#include#includevoid main( ){ char str1[100],str2[100];
int i,j;printf("请输入字符串1:");gets(str1);printf("请输入字符串2:");gets(str2);i=strlen...
回复

使用道具 举报

千问 | 2012-4-16 23:31:02 | 显示全部楼层
gets会自动在数组后加'',但不会判断数组上界。所以容易出错。建议用getchar()单个输入,比较好控制。 修改后: #include #include #include void main() { int i=0; char c; char origPassword[8] = "123456";...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行