Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #15340

Create readonly array of data ?

From paolo <pc8875@nospam.mail.com.br>
Newsgroups comp.lang.c
Subject Create readonly array of data ?
Date 2012-01-02 21:44 +0000
Organization Aioe.org NNTP Server
Message-ID <jdt8fi$e1f$1@speranza.aioe.org> (permalink)

Show all headers | View raw


Please excuse my very poor English, I hope you understand my question.

I want to create a readonly array of data, then a readonly array of a
structure (STRUCT). This is data I access but I want it protected against
accidental change. The following is my test code.

#include "stdafx.h"

struct LVC
{
   unsigned short int lo;
   unsigned short int hi;

};

void main()
{
   //This seems to work
   static const unsigned short int LV[4] =
   {0xAC00,
    0xAC1C,
    0xAC38,
    0xAC54 };

   //THIS DOESN'T WORK. COMPILER COMPLAINS
   static const struct LVC[4] = {
      { 0xAC01, 0xAC1B },
      { 0xAC1D, 0xAC37 },
      { 0xAC39, 0xAC53 },
      { 0xAC55, 0xAC6F },
   };

    unsigned short i,j;

    i = LVC[2].lo;
    j = LVC[2].hi;

}

I use Microsoft Visual C++ Express Edition
(I also would like to get rid of that #include "stdafx.h" if
there is some compiler configuration that will allow me
to do that.)

Thank you.

Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Create readonly array of data ? paolo <pc8875@nospam.mail.com.br> - 2012-01-02 21:44 +0000
  Re: Create readonly array of data ? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-02 17:30 -0500
  Re: Create readonly array of data ? ec429 <ec429@cam.ac.uk> - 2012-01-02 22:33 +0000
  Re: Create readonly array of data ? jt@toerring.de (Jens Thoms Toerring) - 2012-01-02 23:12 +0000
    Re: Create readonly array of data ? Thad Smith <ThadSmith@acm.org> - 2012-01-02 19:46 -0700
  Re: Create readonly array of data ? Roberto Waltman <usenet@rwaltman.com> - 2012-01-03 21:12 -0500

csiph-web