Sos!!!!!

This is a discussion on Sos!!!!! within the C++ Programming forums, part of the General Programming Boards category; wel thisis my first thread over here!!! i wanted to kno what to do if i want the user to ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    2

    Sos!!!!!

    wel thisis my first thread over here!!!
    i wanted to kno what to do if i want the user to input 'n' variables in the same line(separated by spaces)

    'n' being variable(or that too taken as input from the user)

    luking forward to a promp reply!!!!!!!


    sonu

  2. #2
    ... arjunajay's Avatar
    Join Date
    May 2005
    Posts
    203
    I usually use a loop.
    Code:
    for( int i=0; i<no_of_variables; i++){
    cin>>array_name[i]; //Array should be large enough...
                                     //cin reads till it enconters a space a tab or a newline.
    }

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,806
    Input 'n' variables... and do what with them? Store them in a container of some sort so you can operate upon them further?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    2

    Sos

    thanx for the soln but i dont think until u press the return key,u can input a new value

  5. #5
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    Quote Originally Posted by sonu_160
    thanx for the soln but i dont think until u press the return key,u can input a new value
    Try it and see :-)

    It will actually work either way.... input, enter, input, enter ... etc.
    or input, space, input, space , input... enter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SOS, HomeWork in Linked Lists !
    By 4xMpL in forum C Programming
    Replies: 40
    Last Post: 01-01-2009, 02:22 PM
  2. SOS - Can a monolithic kernel be used in a micro-kernel style OS?
    By sean in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-20-2008, 09:30 AM
  3. i'm having trouble to program this!! SOS reply asap
    By Hanz in forum C# Programming
    Replies: 8
    Last Post: 09-07-2005, 07:55 AM
  4. Replies: 5
    Last Post: 12-17-2001, 11:59 AM
  5. a less sevear SOS
    By DarkDays in forum C++ Programming
    Replies: 3
    Last Post: 11-25-2001, 06:54 PM

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