Thread: getchar & cin.get

  1. #1
    Nothing is impossible! 74466's Avatar
    Join Date
    Jan 2006
    Location
    Bloemfontein South-Africa
    Posts
    29

    getchar & cin.get

    What is the actual difference in using
    Code:
    getchar();
    and using
    Code:
    cin.get();

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    One utilizes the cin istream object and one doesn't.
    Sent from my iPadŽ

  3. #3
    Nothing is impossible! 74466's Avatar
    Join Date
    Jan 2006
    Location
    Bloemfontein South-Africa
    Posts
    29
    so wich is better or is some better in some codes and the other in other codes?

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    If you're only including <iostream> then cin.get() is better. If you're only including <cstdio> then getchar() is better.

    In C++ you're most likely gonna be using cin.get().
    Sent from my iPadŽ

  5. #5
    Nothing is impossible! 74466's Avatar
    Join Date
    Jan 2006
    Location
    Bloemfontein South-Africa
    Posts
    29
    okay thanks....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getchar() problem
    By jlharrison in forum C Programming
    Replies: 6
    Last Post: 01-25-2006, 02:49 PM
  2. getchar buffer size
    By oncemyway in forum C Programming
    Replies: 3
    Last Post: 08-02-2005, 12:49 AM
  3. getchar() problem from K&R book
    By anemicrose in forum C Programming
    Replies: 13
    Last Post: 04-04-2004, 11:06 PM
  4. help with getchar lol
    By Taco Grande in forum C Programming
    Replies: 5
    Last Post: 03-18-2003, 09:25 PM
  5. Can anybody take a look at this?
    By TerryBogard in forum C Programming
    Replies: 10
    Last Post: 11-21-2002, 01:11 PM