Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define TAM 2
- void showWords(char** words, int amount);
- int main()
- {
- char **palavras = malloc(TAM*sizeof(void *));
- for(int i = 0; i < 2; i++)
- palavras[i] = malloc(100);
- int i;
- for(i = 0; i < TAM; i++){
- printf("Digite uma palavra: ");
- scanf("%[^\n]s", palavras[i]);
- setbuf(stdin, NULL);
- }
- for(i = 0; i < TAM; i++){
- printf("\n%s\n", palavras[i]);
- }
- showWords(palavras, 2);
- for(int i = 0; i < 2; i++)
- free(palavras[i]);
- free(palavras);
- return 0;
- }
- void showWords(char** words, int amount)
- {
- int iterator;
- for(iterator = 0; iterator < amount; iterator++){
- printf("%s\n", words[iterator]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement