【新手求助】关于一个简单程序的core dump问题,求帮助!!
新手求助~在网上做一个很简单的OJ,题目大概意思如下:
flymouse is poor in EnGlish but his girlfriend is good at English这句话有两个错误:第一个字母没大写,后面G要小写
1. Make the initial letter of the first word of the sentence to be capital.
2. Make the non-initial letters of the non-first words of the sentence to be small.
其实就是一句话首字母要大写,之后的词不管首字母其他要小写。
Flymouse is poor in English but his girlfriend is good at English
Input
The first line contains a single integer t, indicating the number of test cases, followed by one line for each test case. The line for each test case contains a sentence from flymouse's composition. the length of the sentence will be not larger than 10000. For simplicity, punctuations will always be omitted.
Output
There should be one output line per test case containing the correct sentence.
Sample Input
1
flymouse is poor in EnGlish but his girlfriend is good at English
Sample Output
Flymouse is poor in English but his girlfriend is good at English
===========================================================
我的程序代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char s[10002];
int t,a,b,i,len;
scanf("%d",&t);
while(t--)
{
memset(s,0,sizeof(s));
gets(s);
len=strlen(s);
if(s[0]>96&&s[0]<123)
{
s[0]=s[0]-32;
}
a=1;
while(s[a]!=32)
{
a++;
}
b=a+1;
while(s[b]!='32)
{
b++;
}
for(i=1;i<b;i++)
{
if(s[i]>64&&s[i]<91)
{
s[i]=s[i]+32;
}
}
while(a!=len)
{
for(i=a+2;i<b;i++)
{
if(s[i]>64&&s[i]<91)
{
s[i]=s[i]+32;
}
}
a=b;
b=a+1;
while(s[b]!=32'||s[b]!='\0')
{
b++;
}
}
puts(s);
}
return 0;
}
===========================================================
这个程序在linux上运行每次输入第一个数字T后程序就说segment fault(core dump)
我查了一下core dump的问题,在gdb中显示的是倒数第四行“while(s[b]!=32'||s[b]!='\0')”这句话有问题。。但是我实在看不出来问题,,,走投无路来论坛求助了。。