Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*CABEÇALHO
- Arquivo: LISTA 08 - Exercício 07.c
- Objetivo: Escrever uma função similar a strlen da biblioteca do C.
- Autor(a): Ramon Borges.
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- char *nome;
- nome = (char*) malloc(50 * sizeof(char));
- int qtde;
- printf("Informe um nome: ");
- gets(nome);
- qtde = funcaoStrlen(nome);
- printf("\nA palavra %s possui %d letras.", nome, qtde);
- free(nome);
- return 0;
- }
- int funcaoStrlen(char *palavra)
- {
- int cont = 0;
- while(*palavra != '\0')
- {
- cont++;
- palavra++;
- }
- return cont;
- }
Advertisement
Add Comment
Please, Sign In to add comment