Thread: plz help me

  1. #1
    Registered User
    Join Date
    Feb 2011

    Question plz help me

    Hi! I wanna write a program that changes the places of the words of a sentence recursively. suppose that the input is :
    **I****am*fine**.**How*are*you***.******* (the asterisks represent spaces)
    then the output must be :
    but note that the number and the places of spaces are the same as they used to be(only the places of the words have changed). there should be no additional strings other than the main one that stores the input data; which means whatever is done shoud be done on the main string.
    I have come up with the idea of a program that returns the words just like what mentioned but I don't know what to do with the spaces.
    my program is:
    string s;
    void f()
    the problem is that "cin" doesn't get spaces. I'd appreciate it if you help me.
    Last edited by Farnaz; 02-27-2011 at 06:54 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    How To Ask Questions The Smart Way
    Use getline(cin,s) if you want to read a WHOLE line.

    But be careful when you start mixing cin >> var; with the getline method.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. project .... help plz plz plz
    By Hitchhik3R in forum C Programming
    Replies: 13
    Last Post: 10-24-2010, 02:07 PM
  2. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 09:19 PM
  3. [Request] Need Help Plz
    By TylerD in forum Tech Board
    Replies: 4
    Last Post: 01-03-2009, 09:54 AM
  4. Anyone plz help me
    By Rose_Flowers in forum A Brief History of
    Replies: 1
    Last Post: 09-17-2003, 12:01 PM
  5. help plz plz
    By nsssn73 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 08:44 AM

Tags for this Thread