Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<ctype.h>
  4. void split(char arrWord[][100], int &size, char str[]) {
  5. char *stok= strtok(str, " ");
  6. while(stok != NULL) {
  7. strcpy(arrWord[size++], stok);
  8. stok = strtok(NULL, " ");
  9. }
  10. }
  11.  
  12. void rebuid(char arrWord[][100], int size, char str[]) {
  13. strcpy(str, "");
  14. for(int i = 0; i < size; i++) {
  15. if(i < size -1) {
  16. strcat(str, arrWord[i]);
  17. strcat(str, " ");
  18. }else {
  19. strcat(str, arrWord[i]);
  20. }
  21. }
  22. }
  23.  
  24. void nomalizeName(char arr[][100], int size) {
  25. for(int i = 0 ; i < size; i++) {
  26. if(!isupper(arr[i][0])) {
  27. arr[i][0] = toupper(arr[i][0]);
  28. }
  29. }
  30. }
  31.  
  32. void process() {
  33. char arrWord[100][100];
  34. int size = 0;
  35. char s[100] = "";
  36. printf("Enter a string: ");
  37. gets(s);
  38. split(arrWord,size,s);
  39. rebuid(arrWord, size, s);
  40. printf("Chuoi sau khi chuan hoa {%s}",s);
  41. nomalizeName(arrWord,size);
  42. rebuid(arrWord,size,s);
  43. printf("\nTen sau khu chuan hoa {%s}", s);
  44. }
  45.  
  46. int main() {
  47. process();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement