Help with Backward function
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Help with Backward function

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    1

    Post Help with Backward function

    Can someone please help me with my program it says there is no problem with the build but when exe. it displays a bunch of backward 'k' instead of reversing the words entered.

    Problem: Enter in a C-string and use function to display the word backward. (it might help with a pointer but im not sure how to go about it)

    lab10_p2.cpp

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Help with Backward function

    Set a break point in the begin of your display function, Press F5 to start debugging, then press F10 for each next step... and look at the debug windows ("Auto", Watch", ...) to see what happens with your variables... Then you'll be able to know what and why goes wrong.
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,272

    Re: Help with Backward function

    Please post the code here (with code tags) rather than providing a web link. Some of us don't open links from unknown sources so won't be able to provide guidance.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Help with Backward function

    Quote Originally Posted by 2kaud View Post
    Please post the code here (with code tags) rather than providing a web link. Some of us don't open links from unknown sources so won't be able to provide guidance.
    Well, it is not an external link... It is just the attachment to his/her post.
    However, I agree that inserting this code in the OP (with Code tags, of course!) would be much better.
    Victor Nijegorodov

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,057

    Re: Help with Backward function

    Most of your array is just unitialized garbage. When you reverse the entire array, that's what you see. Your loop should only cover the string that was entered, not the entire buffer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center