why I am getting presesntation error?

Programming
Tutor: None Selected Time limit: 3 Days

#include<stdio.h>
#include<string.h>
int main()
{
  char a[10000],ar[100][10000];
  int i,j,k,m,n,l,len[10000],c;
  freopen("input.txt","r",stdin);
  while(gets(a))
  {
  k=0;
  i=0;
  c=0;
  for(j=0; ; ++k)
  {
  if(a[k]==' ' || a[k]=='\0')
  {
  ar[i][j]='\0';
  len[i]=c;
  if(a[k]=='\0') break;
  i++;
  j=0;
  c=0;
  }
  else
  {
  ar[i][j]=a[k];
  c++;
  j++;
  }
  }
  for(m=0; m<=i; m++)
  {
  for(n=(len[m]-1); n>=0; n--)
  {
  printf("%c",ar[m][n]);
  }
  printf(" ");
  }
  printf("\n");
  }
  return 0;
}
here above i have submitted my code?

I am getting presentation error.

I want to know the reason.

Oct 22nd, 2013
Can you post the contents of the file "input.txt" ? And what error are you getting exactly ?
Oct 23rd, 2013

Hey I found out what is wrong. The text from the file is displayed with every word reversed, I fixed it. 

Change the line for(n=(len[m]-1); n>=0; n--) to for(n=0; n<=(len[m]-1); n++) and you are done!

Oct 23rd, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Oct 22nd, 2013
...
Oct 22nd, 2013
Dec 6th, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer