Thread: passing struct to function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    55

    passing struct to function

    Hello all! I'm creating a Win32 App using MSVC++ 6 compiler.
    I'm looking for help because I don't understand why I am getting these errors. I've been reading up on structs in C ... but it hasn't clicked yet. I'm returning pVect so I can use it later in another function and it will be called more than once. I think i'm doing something wrong with my struct, but I cannot pinpoint it from here...is there a better way to pass a struct or use pointers in a different way...so confusing =[
    Code:
    		struct vect2d
            {
                float h;
                float v;
    
            };
    Code:
    	float getMouse(struct vect2d mVect)
            {	
    			
    			float One0;
    			float One1;
    
    			mVect.h = ReadProcessMemory(hand, (void*)0x402AD4B8, &One0,4, &bytes);//169
    			mVect.v = ReadProcessMemory(hand, (void*)0x402AD4BC, &One1,4, &bytes);//170
                return mVect;//171
            }
    Code:
    main.c(169) : warning C4244: '=' : conversion from 'int ' to 'float ', possible loss of data
    main.c(170) : warning C4244: '=' : conversion from 'int ' to 'float ', possible loss of data
    main.c(171) : error C2115: 'return' : incompatible types
    Last edited by silentkarma; 03-05-2008 at 11:21 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with linked list sorting function
    By Jaggid1x in forum C Programming
    Replies: 6
    Last Post: 06-02-2009, 02:14 AM
  2. Acessing a struct after passing to a function
    By bomberto in forum C++ Programming
    Replies: 5
    Last Post: 10-04-2006, 04:29 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. passing struct to function help
    By staticalloc in forum C Programming
    Replies: 4
    Last Post: 10-06-2004, 08:30 AM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM