📄 teststring.c
字号:
#include "stdio.h"
#include "string.h"
#include "ctype.h"
#define truth 1
#define fault 0
#define MAX_CHAR 100
int main(void)
{
int bFirst = truth;
int bBlank = fault;
char * input= " ----Zeng Guang made this functiong 2006-5-4 ---- !" ;
char output[MAX_CHAR];
char temp;
int i=0;// input count
int y=0; //output count
printf("The input is: \n %s",input);
while(input[i] == ' ') //去除开始的空格
i++;
for(;i<=strlen(input); i++)
{
if((isalpha(input[i])) )
{
if((bFirst == truth))
{
if(islower(input[i]))
{
temp = toupper(input[i]);
}
else
{
temp = input[i];
}
bFirst = fault;
}
else
{
temp = input[i];
}
output[y] = temp;
y++;
bBlank = fault;
continue;
}
if((input[i]==' '))
{
if(bBlank == fault)
{
output[y] = ' ';
y++;
bBlank = truth;
bFirst = truth;
}
else;
}
else
{
output[y] = input[i];
y++;
bBlank = fault;
bFirst = fault;
}
}
output[y] = NULL;
printf("\nThe result is:\n %s",output);
printf("\nByeBye!!\n ");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -