C语言字符串首字母大写
#include <stdio.h> #include <string.h> main() { char ch[100]; int i=0,n=0; gets(ch); while(ch[i]!='\0') { if(i==0) { if(ch[i]>='a'&& ch[i]<='z') ch[i]-=32; } else if(ch[i]==' '&& ch[i+1]!=' ') { if(ch[i+1]>='a'&& ch[i+1]<='z') ch[i+1]-=32; } i++; } puts(ch); getchar(); }