Thread: input and oupt in the same line ?

  1. #1
    Registered User
    Join Date
    Jul 2016
    Posts
    1

    input and oupt in the same line ?

    I want to enter a value in the same line that I want to display a particular sentence/word.

    It's the price if a TV in my case.

    After running the program, this is what happens.

    tv:
    20 ( i entered this value after 'tv' was displayed )

    the price is in the next line as you can see.

    But I want it to be this way, where I can enter the price of beside the word itself.

    tv: 20

    ~~~~~~~~~
    thank you

  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
    You could try
    Code:
    printf("tv: ");
    fflush(stdout);
    scanf("%d",&numberOfTelevisions);
    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. How to read a 2 line input
    By BenBusby in forum C Programming
    Replies: 7
    Last Post: 03-13-2013, 07:16 PM
  2. reading line by line - input function
    By Lindira-123 in forum C Programming
    Replies: 11
    Last Post: 02-06-2011, 03:34 PM
  3. Reading Input from a file, line-by-line
    By Acolyte in forum C Programming
    Replies: 8
    Last Post: 09-30-2007, 01:03 PM
  4. How can I read until the end of an input line?
    By Bad_Scooter in forum C++ Programming
    Replies: 4
    Last Post: 07-19-2003, 09:29 PM
  5. Clearing out an input line
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-22-2001, 12:27 PM

Tags for this Thread