what is this suppose to be?

This is a discussion on what is this suppose to be? within the C++ Programming forums, part of the General Programming Boards category; Code: BYTE (*main_data)[1000]; I thought that it might be an array of pointers, but then I saw this line Code: ...

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

    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?
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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, 02: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, 02: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, 10: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

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