Thread: what is this suppose to be?

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

    what is this suppose to be?

    Code:
    BYTE (*main_data)[1000];
    I thought that it might be an array of pointers, but then I saw this line
    Code:
    main_data = malloc(1000);
    But this line contradicts that theory. It would have to allocate 4 kb (not 1) if that was the case.

    I never thought I'd be asking a question like this, but, what does this initilizer really do?

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    It's a pointer to an array. You can make it point to an array:
    Code:
    BYTE ar[1000];
    BYTE (*main_data)[1000] = &ar;
    But I'm not sure if this works under VC++, because traditionally, due to compatibility with stupid code, VC++ interprets &ar as &ar[0] (or just ar).
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-03-2008, 03:10 AM
  2. is this how a function is suppose to work?
    By ktran03 in forum C Programming
    Replies: 14
    Last Post: 11-06-2008, 03:39 AM
  3. Replies: 6
    Last Post: 07-14-2008, 10:51 AM
  4. Program ideas...
    By code987 in forum C++ Programming
    Replies: 3
    Last Post: 11-18-2002, 11:41 PM
  5. How am i suppose to do this???
    By darketernal in forum C++ Programming
    Replies: 10
    Last Post: 10-06-2001, 11:48 AM