Thread: Urgent-Need help with this problem

  1. #16
    Registered User
    Join Date
    Oct 2014
    Posts
    7
    it has not hanged!! Sorry I am new to this forum and don't really know ho it works

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by 1rmohebian
    But when I try "Montana" I need to get "mnnotaa" and I do not I get " mntonaa"
    When I try "Montana" I get "Mntanoa", and a quick check shows that that is correct. Both "mnnotaa" and "mntonaa" are wrong. Furthermore, it is not clear from the code how you would get "mntonaa" in the first place.

    Refer back to my post #5:
    I would write a function that takes a char* that points to the first element of an array of char, and which will then scramble the string stored in that array. I would write the main function to test it. When I am sure that it works, I will then rewrite the main function to read input line by line from the file and call this function in the process of writing the output to another file.
    That is what I did. I copied your function definition (or rather my formatted version thereof) into a source file that has a main function like this:
    Code:
    int main(void)
    {
        char x[] = "Montana";
        printf("%s\n", scramble(x));
        return 0;
    }
    As such, I am reasonably sure that if you have problems when testing with "Montana", the problem does not lie with the implementation of your scramble function.
    Last edited by laserlight; 10-30-2014 at 01:54 PM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Urgent Help...having problem with code
    By blackendstars in forum C Programming
    Replies: 2
    Last Post: 02-20-2013, 04:35 AM
  2. Problem in loop. Please Help. Urgent!
    By jjbuchan in forum C Programming
    Replies: 4
    Last Post: 11-10-2005, 04:46 PM
  3. URGENT! problem with [free()]
    By dr$brown in forum C Programming
    Replies: 6
    Last Post: 01-13-2005, 12:45 PM
  4. Urgent Programming Problem
    By mchap1643 in forum C Programming
    Replies: 5
    Last Post: 10-16-2003, 08:54 AM
  5. P4 Fan problem: Urgent
    By RoD in forum Tech Board
    Replies: 5
    Last Post: 01-15-2003, 12:12 PM