Ⅰ c語言如何把一句英文中的首字母改成大寫
代碼有問題!!換行
符,製表符
,回車,特殊字元佔二個位元組!!還有加入二個空格在一起怎麼處理,問題考慮不周到??
Ⅱ c語言程序題:編成程實現輸入一串英文字母,要求將每個單詞首字母改成大寫字母並輸出
#include <stdio.h>
#include <conio.h>
main()
{
char str[100] = {0};
printf( "input:\n" );
scanf( "%s",str );
int i = 0;
if( str[0]>='a' && str[0]<='z' ) str[0]=str[0]-'a'+'A';
while( str[i] != '\0' )
{
if( str[i] == ' ' )
{
if( str[i+1]>='a' && str[i+1]<='z' )
{
str[i+1]=str[i+1]-'a'+'A';
i++;
}
}
}
}
Ⅲ C語言的一到題目,將一行字元 每個英文的首字母改成大寫字母
輸入N的回車 被第一個gets讀走了。
加一個getchar就好了。
scanf("%d",&N);
getchar();
.....
Ⅳ (C語言編程)輸入一個英文句子,將每個英文單詞的頭字母變為大寫
#include <stdio.h>
#include <ctype.h>
main()
{ char s[80],*p;
printf("輸入一個字元串:");
gets(s);
p=s;
while(*p)
{
while(!isalpha(*p))
p++;
if(*p>='a'&&*p<='z')
*p=*p-32;
while(isalpha(*p))
p++;
}
printf("修改後的字元串:");
puts(s);
}
運行結果如下:
輸入一個字元串:how are You,fine thanks!
修改後的字元串:How Are You,Fine Thanks!
Press any key to continue
Ⅳ c語言問題 將首字母變為大寫
#include<stdio.h>
int main()
{
int i;
int word;
char str[200];
printf("請輸入字元串:");
while(gets(str)!=NULL)
{
printf("修改後的字元串為:");
word=0;
for(i=0;str<i>!='