Define Please

This is a discussion on Define Please within the C++ Programming forums, part of the General Programming Boards category; What exactly does flush do and this thing: ->?? Thanks...

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

    Define Please

    What exactly does flush do and this thing: ->??


    Thanks

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    flush() function is used to force the operating system to write the data to the physical drive or other output stream. The behavior for inputstreams is undefined, although some compuilers have implemented it to remove all keys from the keyboard buffer.

    -> is the operator for pointers to reference one of the structure or class's objects
    Code:
    struct mystruct
    {
       int x;
    }
    
    struct mystruct * pstruct = malloc(sizeof(struct mystruct));
    pstruct->x = 0;

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    If you have this:
    Code:
    myPtr->display();
    the '->' is shorthand for:
    Code:
    (*myPtr).display();

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    So why not just use a reference if it is for a pointer to reference something?

    Or do I misunderstand.

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Because it makes things much much easier to read and understand.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer within a Struct
    By Bladactania in forum C Programming
    Replies: 11
    Last Post: 04-03-2009, 11:20 PM
  2. Why?!?
    By p3rry in forum C Programming
    Replies: 3
    Last Post: 01-08-2009, 12:52 PM
  3. size of an integer pointer
    By onebrother in forum C Programming
    Replies: 5
    Last Post: 07-09-2008, 12:49 PM
  4. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 09:22 AM
  5. float toolbar!
    By c-- in forum Windows Programming
    Replies: 5
    Last Post: 02-04-2003, 09:44 AM

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