By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,068 Members | 867 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,068 IT Pros & Developers. It's quick & easy.

I am receiving abnormal program termination

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main() {
  4. char str[1]; char ch;
  5. printf("Enter the String: ");
  6. gets(str);
  7. strrev(str);
  8. printf("the reverse string is %s",str);
  9. return 0;
  10. }
  11. reverse(char *ch)
  12. {
  13. char *t, temp;
  14. t = ch;
  15.  while (*t =='')
  16. t--;
  17. t++;
  18. while (ch>t); 
  19. {
  20. temp = *ch
  21. *ch != *t;
  22. *t = temp;
  23. ch++;
  24. t--;
  25. return 0;
  26. }
  27. }
4 Weeks Ago #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 260
I am receiving abnormal program termination
A build is able to terminate abnormally during runtime after it is generated from the error-free code. This doesn't seem the case with the posted code.
4 Weeks Ago #2

Banfa
Expert Mod 5K+
P: 8,950
Look at line 4, how long is the array str?
When you call gets at line 6 how many characters do you type in?

What happens if you only type 1 character?
What if you type more than 1?
What if you type lots?


gets is a dangerous function because it does not limit the number of characters entered, gets is a much better function because it does.
4 Weeks Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.