I'm programming to reverse the word order, it's okay, but why does the first character of my string have an enter? And how do I avoid thist
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TAM 50
int main(){
int i,j,t;
char str[TAM],str2[TAM];
printf("Digite a string:");
fgets(str,TAM,stdin);
setbuf(stdin,NULL);
t = strlen(str);
for(i=0,j=(t-1);i<t;i++,j--){
str2[i] = str[j];
}
printf("str1:%s\nstr2:%s\n\n",str,str2);
}
input:"oi"
output:" io"