#include <stdio.h> #include <ctype.h> int main(int argc, char * argv[]) { char buf[100]; char *p; long ss; long reps = 100000000;
system("date"); strcpy(buf, "i think therefore i am"); printf("%s\n", buf); for(ss=0; ss < reps; ss++) { for(p = buf; (*p = ((p == buf) || *(p-1) == ' ' ? toupper(*p) : *p)) != '\0'; p++); } printf("\n"); printf("%s\n", buf); system("date"); printf("==========================\n"); system("date"); strcpy(buf, "i think therefore i am"); printf("%s\n", buf); for(ss=0; ss < reps; ss++) { for(p = buf; *p != '\0'; p++) { if(p == buf) *p = toupper(*p); if(*(p-1) == ' ') *p = toupper(*p); } } printf("\n"); printf("%s\n", buf); system("date"); }
|