Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Palindrome problem
If I run the code as written it works fine with word in main function defined up front. If I try and change the main function to accept input with fgets or scanf I get core dump error. Can anyone tell me why? https://code.sololearn.com/cOhpw23t893N/?ref=app
4 Answers
+ 3
Remove the orgc size 25. like just orig[] then try...
orgc[25]={r,a,s,e,s,a,r};
Then strlen(orig) will return 25 not 7.
Then orig[origlength - (i+1)] =>orig[25] =>fatal error...
+ 2
You need to initialize a variable before using it, but in this case you don't need j (you can reuse i instead). Also other parts of the code can be optimized. Eg:
https://code.sololearn.com/c6FD70icKRLk/?ref=app
+ 1
Thanks a million devanville!
0
Thank you to both! I think either way i had to initialize j but also didnt know i could pass a string into function with empty [].