You haven't added a null character after the end of your word in backwards (even though you have allocated space for it) so strlen() doesn't know where it ends.
You haven't added a null character after the end of your word in backwards (even though you have allocated space for it) so strlen() doesn't know where it ends.
Last edited by Golf7; 09-22-2015 at 09:36 AM.
By the way, "stringManipulation" is a vague name for your function. As it seems that you want to print the string backwards, give it a name along those lines.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Thank you, laserlight, I have since revised the name to revereString.
In case you were confused by always getting 8 from sizeof(backwards), remember that this will give you the size of a char pointer and not the size of the memory you allocated with malloc (which backwards points to).
Last edited by Golf7; 09-22-2015 at 11:05 AM.