a simple question. plz help

This is a discussion on a simple question. plz help within the C Programming forums, part of the General Programming Boards category; i need to write a program that reads input character strings form the keyboard and prints them in reverse order ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    2

    Question a simple question. plz help

    i need to write a program that reads input character strings form the keyboard and prints them in reverse order
    .... i know how to do the 2nd part ( print the numbers in reverse order ) but i dont know how to write a program which reads inputs for this array because the size of array in unknown , and i guess the program should also know when the inputs are finished and it has to print them in reverse order
    plzzz somebody help me

  2. #2
    Aia
    Aia is offline
    Beautiful to C Aia's Avatar
    Join Date
    Jun 2007
    Posts
    124
    An option would be to declare a reasonable size array and use a function that would read from the keyboard up to that limit - 1.

    i.e.
    Code:
    char input[255] = { '\0' };
    
    fgets( input, sizeof( input ), stdin );
    Check that input is successful and clear the stdin of unwanted characters if necessary.
    When the eagles are silent, the parrots begin to jabber. ~Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 09:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-21-2005, 12:41 AM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM

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