I want this code to print each word backwards, but is not printing the last word, I guess I'm missing something very basic here.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int l;
printf("lenght: ");
scanf("%i",&l);
char str[l][100];
int lenght[l];
for(int i=0; i<l; i++)
{
printf("%i : ",i);
scanf("%s",str[i]);
lenght[i] = strlen(str[i]);
}
for(int i=l-1; i>0; i--)
{
for(int j=lenght[i-1]; j>=0; j--)
{
printf("%c",str[i][j]);
}
printf("\n");
}
return 0;
}
i >= 0in this for loop:for(int i=l-1; i>=0; i--)for(int i=l; i-- >0;)for the outer loop, andfor(int j=lenght[i]; j-- >0;)for the inner.