Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * main.c
- *
- * Created on: 03/06/2013
- * Author: sombriks
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- /*
- * receber uma string e contar qntos a tem nessa string
- */
- int main(int argc, char **argv) {
- // se escrever muito dá erro
- char *buffer = malloc(1024 * sizeof(char));
- memset(buffer, '\0', 1024);
- printf("digite uma linha de texto (max. 1024 caracteres):\n");
- gets(buffer);
- int qtda = 0;
- int i = 1024;
- while (i--)
- if (buffer[i] == 'a')
- qtda++;
- printf("a linha digitada contém %i letras a\n", qtda);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement