Can anyone help me, we have this assignment. A program that will ask for the full name (first name and last name) and the birthday. then the program will output the first letter of full name and last name in capital.
ex.
Input name: dante lopez
Your name is Dante Lopez
I have a problem in making the first letter of the last name into upper case.
Here is my C code:
Hope someone can help me...Code:#include <stdio.h> #include <conio.h> #include <string.h> #include <ctype.h> void main() { int x=0, mm,dd,yyyy,ctr,i,count; char name[25],choice; clrscr(); puts("Input your name: "); gets(name); count=strlen(name); //name[25]=tolower(name[25]); name[0]=toupper(name[0]); for(x=0;name[x]<=count;x++) { i = isspace (name[x]); if(i==1) name[x++]=toupper(name[x++]); } printf("Input your birthday [mm/dd/yyyy]: "); scanf("%d/%d/%d",&mm,&dd,&yyyy); printf("\n\n"); puts(name); if(mm==01) printf("January %d %d",dd,yyyy); else if(mm==02) printf("February %d %d",dd,yyyy); else if(mm==03) printf("March %d %d",dd,yyyy); else if(mm==04) printf("April %d %d",dd,yyyy); else if(mm==05) printf("May %d %d",dd,yyyy); else if(mm==06) printf("June %d %d",dd,yyyy); else if(mm==07) printf("July %d %d",dd,yyyy); else if(mm== 8) printf("August %d %d",dd,yyyy); else if(mm== 9) printf("September %d %d",dd,yyyy); else if(mm==10) printf("October %d %d",dd,yyyy); else if(mm==11) printf("November %d %d",dd,yyyy); else if(mm==12) printf("December %d %d",dd,yyyy); else printf("Month should be 1-12"); printf("\n\nWould still like to input [y/n]: "); scanf("%s",&choice); getch(); }



LinkBack URL
About LinkBacks



I can't seem to understand the strchr(). I'm having trouble in this string manipulation, can you please fix my loop part in my code. 