Thread: Help with getting data

  1. #1
    peter7601
    Guest

    Unhappy Help with getting data

    hi, here is my problem.
    "enter the two characters:" user enters "ac"
    this is the prompt im giving and the user enters the data in the correct format. i just need to get it in the way that i can be able to distinguish between the two characters later on. ive tried a few different ways, im using printf and scanf except whenever i do this the 2nd character ends up being not what i wanted. thanks in advance

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    3
    well try gets().

    #include <stdlib.h>

    char input[2]; //user input

    void main
    {
    printf("Enter something: ");
    gets(input);
    printf("\n");

    printf("%c, %c\n", input[0], input[1]);
    }

    [COLOR=green]

    now both the variables the user entered are in input[0] and
    input[1]. that is the easiest way.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Bitmasking Problem
    By mike_g in forum C++ Programming
    Replies: 13
    Last Post: 11-08-2007, 12:24 AM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  5. Replies: 1
    Last Post: 07-31-2002, 11:35 AM