Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*CABEÇALHO
- Arquivo: LISTA 08 - Exercício 09.c
- Objetivo: Transforma uma palavra de minuscula para maiuscula.
- Autor(a): Ramon Borges.
- */
- #include <stdio.h>
- #include <stdlib.h>
- //PROTOTIPO DE FUNÇÕES
- void maiuscula(char *palavra);
- int main()
- {
- char *nome;
- nome = (char*) malloc(50 * sizeof(char));
- printf("Informe uma palavra com letras minusculas: ");
- gets(nome);
- maiuscula(nome);
- printf("%s", nome);
- free(nome);
- return 0;
- }
- void maiuscula(char *palavra)
- {
- int diferenca;
- diferenca = 'A' - 'a';
- while(*palavra != '\0')
- {
- if(*palavra >= 'a') //Impede que uma letra maiúscula seja mudada.
- *palavra += diferenca;
- palavra++;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment