Thread: Hey!

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    4

    Hey!

    I just posted like few second ago i know. i'm sorry about that but i have one more major question. in my programs i use cin.ignore(); a lot i was wondring if in the beganining of the program i could write som ething like #define cin.ignore(): = done; ? because i'm kind of geting tired of writteing all that. i learned that #define are varibles that are used all over the program not just in on section of code or something like that. if this is not true could someone point me in the right direction :-D

    -jumbo

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    in my programs i use cin.ignore(); a lot
    why?

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >in my programs i use cin.ignore(); a lot
    Then you're likely not doing proper input as you should. I imagine that you use ignore to clear junk from the stream that you left from your last request for input. It's generally best to take input as an entire line so that you can keep the stream clean and parse the input at your leisure.

    And you should also avoid #define in C++ until you're experienced enough to know when to use it. Or more importantly, that there are better options most of the time.
    My best code is written with the delete key.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Echo the advice given above, but in future, if you find yourself doing a routine quite often, you can group that routine into a separate function or loop, and use those constructs instead. In this case, easiest just to use the hot keys for copy and paste, don't you think?

    Also, I suggest you use more descriptive subject titles, as advised in the forum guidelines (http://cboard.cprogramming.com/annou...ouncementid=51)

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    writing 'done' isn't realy much less then writing 'cin.ignore();' but you would create such a defination like this.
    Code:
    #define done cin.ignore();

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hey, need help with Dropping ball and Bouncing
    By thynksheraze in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2003, 03:05 PM
  2. Hey
    By REMY in forum C++ Programming
    Replies: 1
    Last Post: 01-22-2003, 11:06 PM
  3. Hey all...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 11-01-2002, 08:56 PM