String output

This is a discussion on String output within the C++ Programming forums, part of the General Programming Boards category; Code: int main() { string s = "12a34b56c78d"; int size = 12; writeStuff(s,size); return 0; } // end main void ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    10

    String output

    Code:
    int main()
    { string s = "12a34b56c78d";
       int size = 12;
       writeStuff(s,size);
       return 0;
    } // end main
    void writeStuff(string s, int size)
    {     if (size > 0)
         {     cout << s.substr(size-1, 1);
                writeStuff(s, size-3);  
          }  // end if
    }  // end writeStuff
    What is supposed to be the output of this?

  2. #2
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    What the hell? Are you just posting your homework for us to answer? I thought you needed help before so I did but this is the third place you have posted dodgy code asking "Whats the output?"


    What do you *think* the output is?
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,665
    Download and install GCC, the GNU Compiler Collection - GNU Project - Free Software Foundation (FSF) and Code::Blocks, then build, link, and run the program, and you have your answer.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IDE for C embedded advanced editing
    By Undici77 in forum Tech Board
    Replies: 32
    Last Post: 01-16-2010, 04:17 PM
  2. Help for my assigment
    By cloverdagreat in forum C Programming
    Replies: 16
    Last Post: 11-21-2009, 11:18 AM
  3. Replies: 4
    Last Post: 04-03-2007, 05:57 AM
  4. Replies: 4
    Last Post: 03-03-2006, 01:11 AM
  5. Another overloading "<<" problem
    By alphaoide in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2003, 10:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21