getchar() to work twice

This is a discussion on getchar() to work twice within the C Programming forums, part of the General Programming Boards category; how do i get getchar() to work twice. example char *bleh= getchar(); char *hmm= getchar(); or is there a better ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    getchar() to work twice

    how do i get getchar() to work twice.

    example
    char *bleh= getchar();
    char *hmm= getchar();

    or is there a better function for getting a string, actually?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    fgets()

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Your example is wrong, because getchar, as the name implies, gets a char, not a string. Second, your pointers don't actually point at anything, so that would be an incorrect assignment.

    Consider reading the FAQ on getting a line or string from the user.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 04-25-2009, 09:51 PM
  2. getchar() problem
    By jlharrison in forum C Programming
    Replies: 6
    Last Post: 01-25-2006, 01:49 PM
  3. getchar buffer size
    By oncemyway in forum C Programming
    Replies: 3
    Last Post: 08-02-2005, 12:49 AM
  4. getchar() problem.
    By caroundw5h in forum C Programming
    Replies: 11
    Last Post: 06-17-2004, 07:10 PM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM

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