structure problems in windows program.

This is a discussion on structure problems in windows program. within the Windows Programming forums, part of the Platform Specific Boards category; My console app. works with the code below why does my Win32 app choke up on these errors? Code: // ...

  1. #1
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    structure problems in windows program.

    My console app. works with the code below why does my Win32 app choke up on these errors?

    Code:
    // test struct program console app.
    #include <stdio.h>
    
    struct test
    {
    	int x;
    	int y;
    
    } *pPoint, *pp, Point[4] ={
    	5,6,
    	7,8,
    	9,10,
    	11,12,};
    
    int main()
    {
    	for(int count = 0; count<4; count++)
    	{
    		pp = &Point[count];
    		printf("Point[%d].x = %d\t Point[%d].y = %d\n", count, Point[count].x, count, Point[count].y);
    	}
    	puts("");
    	return 0;
    }



    // My windows program...contains this as a global structure.
    Code:
    struct test
    {
    	int x;
    	int y;
    
    }Point[4], *pp;
    pp = &Point[0];

    and give me these errors:

    error C2501: 'pp' : missing storage-class or type specifiers
    error C2040: 'pp' : 'int' differs in levels of indirection from 'struct test *'
    error C2440: 'initializing' : cannot convert from 'struct test *' to 'int'
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Code:
    pp = &Point[0];
    That's assignment, not initialization.

  3. #3
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    So are you saying I need to initialize first? I didn't think I needed to initialize it first!
    I just want it to point to the first structure like in my console app.
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  4. #4
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Are you doing all this globally?
    You can't do global assignments, only global initializations.
    Do it in your main function instead.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 02:42 AM
  2. Program works on Windows XP and 2000, not on 98 or ME
    By MidnightlyCoder in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2006, 03:36 PM
  3. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  4. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 12:14 PM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 06:31 PM

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