Thread: array of strings

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    array of strings

    Hello all!
    I am new to this website.I am weak in c++ and need yur help.
    here is my question.

    1) Write a program to read an array of strings and print its contents backwards. For ex: the array of strings is
    Hello
    Programming
    World
    Then the program should print “World Programming Hello”

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Can you
    - write a program that reads one string, and print it?
    - write a program which reads an array of strings, and prints it forwards?

    If you can do these things, then that goes a long way to making us think you're attempting your own homework, and not just dumping it on a forum for someone else to do.

    If you can't do these simple steps, then we have some other things which need to be explained before we get to the complicated bit of printing in reverse.
    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.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    87
    just cin the strings and then cout them in a for loop with a decreasing integer, you will also need a way to cin them without ignoring spaces, i recomend multiple char arrays and getline
    Last edited by bobknows; 02-20-2011 at 06:51 PM. Reason: lotsa speling erorz ;P

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No char arrays! Period.
    And let's let the OP show some effort first.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Build an array of strings dynamically
    By Nazgulled in forum C Programming
    Replies: 29
    Last Post: 04-07-2007, 09:35 PM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  4. Array of strings in C
    By szill in forum C Programming
    Replies: 10
    Last Post: 02-22-2005, 05:03 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM