Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<ctype.h>
- void split(char arrWord[][100], int &size, char str[]) {
- char *stok= strtok(str, " ");
- while(stok != NULL) {
- strcpy(arrWord[size++], stok);
- stok = strtok(NULL, " ");
- }
- }
- void rebuid(char arrWord[][100], int size, char str[]) {
- strcpy(str, "");
- for(int i = 0; i < size; i++) {
- if(i < size -1) {
- strcat(str, arrWord[i]);
- strcat(str, " ");
- }else {
- strcat(str, arrWord[i]);
- }
- }
- }
- void nomalizeName(char arr[][100], int size) {
- for(int i = 0 ; i < size; i++) {
- if(!isupper(arr[i][0])) {
- arr[i][0] = toupper(arr[i][0]);
- }
- }
- }
- void process() {
- char arrWord[100][100];
- int size = 0;
- char s[100] = "";
- printf("Enter a string: ");
- gets(s);
- split(arrWord,size,s);
- rebuid(arrWord, size, s);
- printf("Chuoi sau khi chuan hoa {%s}",s);
- nomalizeName(arrWord,size);
- rebuid(arrWord,size,s);
- printf("\nTen sau khu chuan hoa {%s}", s);
- }
- int main() {
- process();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement