teststring.c
来自「本文件是帮同事做的一个小程序,要求是输入一行字符,如果是字符串,那么把第一个字母」· C语言 代码 · 共 83 行
C
83 行
#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 + =
减小字号Ctrl + -
显示快捷键?