truko

fix_name.c

Aug 22nd, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. int fix_name(char nome[])
  6. {
  7.         printf("digite o nome a ser consertado: \n");
  8.         fgets(nome, 150, stdin);
  9.         nome[strlen(nome)-1] = '\0';
  10.         char c = ' ';
  11.         for(int i=0;i<strlen(nome);i++)
  12.         {
  13.                 if(islower(nome[0]))
  14.                 {
  15.                         nome[0] = toupper(nome[0]);
  16.                 }
  17.                 else if(nome[i]==c)
  18.                 {
  19.                         nome[i+1] = toupper(nome[i+1]);
  20.                 }
  21.         }
  22.         //printf("%s", nome);
  23.         puts(nome);
  24.         return 0;
  25. }
  26.  
  27. int main(void)
  28. {
  29.         char name[100];
  30.         fix_name(name);
  31.         return 0;
  32. }
Add Comment
Please, Sign In to add comment