Thread: what the hell!

  1. #1
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182

    what the hell!

    ok, so i am typing code for a nifty structure.

    Code:
    typedef struct c3
    {
        int x;
        int y;
        int z;
    }coords;

    and in visual c++ 6.0 professional i do this:

    coords mycoords;

    then if I type mycoords.x, it will not bring up the code completion!
    what the hell is going on!

    this is absolutely essential to me!!!

    any help appreciated,
    spoon_
    {RTFM, KISS}

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    137
    I'm not sure but try
    c3.mycoords;

    then access using mycoords.x

    I think that'll do it.
    http://uk.geocities.com/ca_chorltonkids

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    170
    change:

    Code:
    typedef struct c3
    {
        int x;
        int y;
        int z;
    }coords;
    to this:
    Code:
    struct coords
    {
        int x;
        int y;
        int z;
    };
    
    coords mycoords;
    You had already created an instance and called it coords. This way we call the struct coords and you can create instances like you wanted.
    Last edited by bonkey; 09-29-2002 at 09:59 AM.
    Best Regards,

    Bonkey

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    have you set the coordinates to some value before you try to access it? If not, the values are undefined.
    And you don't need the c3 in your type definition.
    Code:
    typedef struct
    {
       int x;
       int y;
       int z;
    }COORDS;
    
    COORDS MyCoords;
    
    MyCoords.x = 12;
    MyCoords.y = 46;
    MyCoords.z = -8;
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182

    doh

    it doesnt work with any structure. it works when i do a console project, but not when i do win32api code. it makes no sense at all.
    {RTFM, KISS}

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Post a complete, but small, piece of code that you cannot get to work.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well two things. First off, the code completion can be annoying and it may be a blessing that it is broken. And secondly, what you had to begin with was fine. You could try these:

    Code:
    //#1
    struct c3 {
      int x, y, z;
    };
    typedef struct c3 coords;
    
    //#2
    typedef struct c3 coords;
    struct coords {
      int x, y, z;
    };
    Anyways, you shouldn't have to go through that much trouble for something so trivial (especially since all ways of doing this are ANSI-C and ANSI-C++ compatible).

  8. #8
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182

    ....

    Alright, it is no blessing that it doesnt work!!!!

    I hate having to constantly look up the members of structs and unions in MSDN or the web.

    Call me lazy, but I am not. I like(d) the convenience of code completion. I have too much to memorize in college as it is.

    Oh well. I will not give up! FORTE code completion works fine, DAMN YOU MICROSOFT!

    heres the code example you wanted, Hammer:

    Code:
    #include<windows.h>
    #include<winsock.h>
    #include "resource.h"
    
    SOCKADDR_IN myinfo;
    
    
    LRESULT CALLBACK DialogProc(HWND, UINT, WPARAM, LPARAM);
    
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nShowCmd)
    {
    	MSG msg;
    	HWND hWnd;
    	
    	hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MainDlg), NULL, (DLGPROC)DialogProc);
    
    	ShowWindow(hWnd, nShowCmd);
    
    	while(GetMessage(&msg, NULL, 0, 0))
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    	return 0;
    }
    
    
    LRESULT CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	switch(message)
    	{
    	case WM_INITDIALOG:
    		{
    			SendMessage(hWnd, WM_SETICON, ICON_SMALL, LPARAM(LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION))));
    			SendMessage(hWnd, WM_SETICON, ICON_BIG	, LPARAM(LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION))));
    			return TRUE;
    		}
    	case WM_COMMAND:
    		{
    			switch(LOWORD(wParam)
    			{
    			case IDC_CLICK_OK:
    				{
    					
    					//myinfo. does not work here!
    					return TRUE;
    				}
    			}
    			return FALSE;
    		}
    	case WM_DESTROY:
    		{
    			PostQuitMessage(0);
    			return TRUE;
    		}
    	case WM_CLOSE:
    		{
    			DestroyWindow(hWnd);
    			return TRUE;
    		}
    	}
    	return FALSE;
    }
    There ya are. I don't know what the deal is!!!! =(

    spoon_
    Last edited by spoon_; 09-29-2002 at 08:02 PM.
    {RTFM, KISS}

  9. #9
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    That is a fair argument. You could, alternatively, download the docs. I have the old docs, but they still get the job done. Nonetheless, I can't explain the problem but the best thing to do would be to complain to microsoft. As you programmer you know that you can't fix bugs that you don't know exist.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What the hell!? Crashes and memory leaks?
    By pobri19 in forum C++ Programming
    Replies: 3
    Last Post: 09-26-2008, 05:45 AM
  2. operator from hell
    By algi in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 12-24-2004, 07:36 AM
  3. DLL Hell
    By Sentaku senshi in forum Windows Programming
    Replies: 9
    Last Post: 11-21-2002, 08:06 AM
  4. Living in the 00'S
    By mithrandir in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-21-2002, 09:31 AM
  5. Heaven, Hell, and Aetheists/Non-believers
    By Aran in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 09-10-2001, 02:18 PM