Results 1 to 4 of 4

Thread: confused with Handle pointer

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Location
    cobwebbed to PC
    Posts
    311

    confused with Handle pointer

    Hi Folks

    Pointers in C is something I always end up confusing myself with...

    I have a function that is passed a pointer to a handle. this function should then pass that pointer on to a sub-function.
    Code:
    int txSerial (HANDLE *hComm) {
      // Do some stuff using *hComm here.
      // EG. 
      if (*hComm == INVALID_HANDLE_VALUE) {
        printf("Comm port returned an invalid handle\n");
        return 1;
      }
      return 0;
    }
    
    int txSPI (HANDLE *hComm) {
      return (txSerial(hComm));  //<<--- CONFUSED HERE.
    }
    
    int main (void) {
      HANDLE hComm1;
      int x;
      // Assign a handle to hComm1.
    
      x = txSPI(&hComm1);
      return x;
    }
    My confusion is where I call the sub-function txSerial().
    Should I be passing *hComm or hComm ???
    Got my thinking all knotted up here, help much appreciated, Thanks
    Last edited by wolf99; Jun 4th, 2011 at 07:47 AM.
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width