Hey!

This is a discussion on Hey! within the C++ Programming forums, part of the General Programming Boards category; I just posted like few second ago i know. i'm sorry about that but i have one more major question. ...

  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,662
    in my programs i use cin.ignore(); a lot
    why?

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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, 02:05 PM
  2. Hey
    By REMY in forum C++ Programming
    Replies: 1
    Last Post: 01-22-2003, 10:06 PM
  3. Hey all...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 11-01-2002, 07:56 PM

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