I decided to make this code simple, where I have an empty vector and a function that fills it only with a letter that the user types, but I can not print.
If I use that commented% com, it works, but if I print out it does not come out of the blue. And if I try to print it in the printf()
function, it exits with m 2 at the end. Why?
#include <stdio.h>
#include <string.h>
#define TAM 3
void preencher(char *str, char letra){
int c;
for (c=0; c<TAM; c++){
*str = letra;
//printf("%c", *str);
*str++;
}
while (*str) printf("%c", str++);
}
int main(){
char str[TAM], letra;
scanf("%c", &letra);
preencher(&str, letra);
}