By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,118 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,118 IT Pros & Developers. It's quick & easy.

Create readonly array of data?

P: n/a
I want to create a readonly array of data, then a readonly array of a
structure. 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'm using Microsoft Visual C++ Express Edition
(I'd also like to get rid of that #include "stdafx.h" if
there's some compiler configuration that will allow me
to do that.)
Jan 1 '07 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Susan Rice a écrit :
//THIS DOESN'T WORK. COMPILER COMPLAINS
static const struct LVC[4] = {
static const struct LVC is the type. You have to give a *name*
to that array.

for instance
static const struct LVC MyTable[4] = {
etc

Then you use THAT name:
i = MyTable[2].lo;
j = MyTable[2].hi;

jacob

P.S.
it is not void main() but int main(void).
But that is a detail.

---
http://www.cs.virginia.edu/~lcc-win32
A free C compiler for windows
Jan 1 '07 #2

P: n/a
Susan Rice wrote:
I want to create a readonly array of data, then a readonly array of a
structure. This is data I access but I want it protected against
accidental change. The following is my test code.

#include "stdafx.h"
See below about this.
struct LVC
It's generally prefered by most to reserve all caps for macros.
{
unsigned short int lo;
unsigned short int hi;
};

void main()
This should be int main(void)
{
//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] = {
LVC is the name of struct type that you created above. What you wanted
was something like:

static const struct LVC LVC_array[4] = {
{ 0xAC01, 0xAC1B },
{ 0xAC1D, 0xAC37 },
{ 0xAC39, 0xAC53 },
{ 0xAC55, 0xAC6F },
};

unsigned short i,j;

i = LVC[2].lo;
j = LVC[2].hi;
Then change these two names as well.
}

I'm using Microsoft Visual C++ Express Edition
(I'd also like to get rid of that #include "stdafx.h" if
there's some compiler configuration that will allow me
to do that.)
This has to do with pre-compiled headers in VC++. I don't know
specifically to correct that in Express, but check your project
settings to remove any dependence. If you can't figure it out, you'll
need a Microsoft newsgroup.


Brian
Jan 1 '07 #3

P: n/a


I'm using Microsoft Visual C++ Express Edition
(I'd also like to get rid of that #include "stdafx.h" if
there's some compiler configuration that will allow me
to do that.)
when u create your project in msvc++

new project->Win32(win32 console app template is automatically
selected) ->
(enter a name for the project)->next->select "empty project"
option->finish

then add the header and source files that u need.

and more simply...
new project->select "general " option from the Project type window
->finish

//THIS DOESN'T WORK. COMPILER COMPLAINS
static const struct LVC[4] = {
{ 0xAC01, 0xAC1B },
u did not name the "template" ..it has been answered above

regards

Jan 1 '07 #4

P: n/a
"rhle.freak" wrote:
>
>I'm using Microsoft Visual C++ Express Edition
(I'd also like to get rid of that #include "stdafx.h" if
there's some compiler configuration that will allow me
to do that.)

when u create your project in msvc++
U never posted in this thread. I don't believe he even uses
c.l.c. If you refrained from snipping attributions it would be
easier to follow this. In addition msvc++ is system specific and
off-topic here.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Jan 1 '07 #5

P: n/a
CBFalconer said:
"rhle.freak" wrote:
>>
>>I'm using Microsoft Visual C++ Express Edition
(I'd also like to get rid of that #include "stdafx.h" if
there's some compiler configuration that will allow me
to do that.)

when u create your project in msvc++

U never posted in this thread. I don't believe he even uses
c.l.c.
I believe he has done so (although I admit it may have been cp rather than
clc) - a month or so ago.

If you refrained from snipping attributions it would be
easier to follow this. In addition msvc++ is system specific and
off-topic here.
Will you not take pity on someone who appears to be trying to coax his
Microsoft implementation into conforming mode?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jan 1 '07 #6

P: n/a
"rhle.freak" <rh********@gmail.comwrites:
[...]
when u create your project in msvc++
[...]
then add the header and source files that u need.
[...]
u did not name the "template" ..it has been answered above
Please don't use silly abbreviations like "u" for "you". It makes
your articles harder to read, and a lot of people just won't bother.

And please don't snip attribution lines (lines of the form
"So-and-so writes:").

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 1 '07 #7

P: n/a


On Jan 1, 7:57 pm, CBFalconer <cbfalco...@yahoo.comwrote:
"rhle.freak" wrote:
I'm using Microsoft Visual C++ Express Edition
(I'd also like to get rid of that #include "stdafx.h" if
there's some compiler configuration that will allow me
to do that.)
when u create your project in msvc++U never posted in this thread. I don't believe he even uses
c.l.c. If you refrained from snipping attributions it would be
easier to follow this. In addition msvc++ is system specific and
off-topic here.

--
please do check the earlier thread "stack" which i had posted a few
days ago! ! regarding using msvc++ ,yes its a specific problem and off
topic but there is no harm if i am using the same compiler n can help
someone with something really simple and please do forgive me because
i am new to using Usenet
(Google groups to be specific) and my format of posting was wrong,i
will definitely try to improve on that!!

Jan 2 '07 #8

P: n/a
"rhle.freak" wrote:
CBFalconer <cbfalco...@yahoo.comwrote:
>"rhle.freak" wrote:
>>I'm using Microsoft Visual C++ Express Edition
(I'd also like to get rid of that #include "stdafx.h" if
there's some compiler configuration that will allow me
to do that.)
>>when u create your project in msvc++

U never posted in this thread. I don't believe he even uses
c.l.c. If you refrained from snipping attributions it would be
easier to follow this. In addition msvc++ is system specific and
off-topic here.

please do check the earlier thread "stack" which i had posted a few
days ago! ! regarding using msvc++ ,yes its a specific problem and off
topic but there is no harm if i am using the same compiler n can help
someone with something really simple and please do forgive me because
i am new to using Usenet
(Google groups to be specific) and my format of posting was wrong,i
will definitely try to improve on that!!
'Another thread' has nothing to do with it. Articles need to stand
alone. That is the point of quoting relevant matter. You would be
well advised to get a proper newsreader and access usenet directly
instead of through the flawed google interface. Also never use
silly geekspeak, such as 'u' and 'n' abbreviations. They only
serve to annoy and make reading hard, especially for non-English
speakers.

Just delete the #include <stdafx.hand #include the appropriate
standard C includes. The C-library link below will be useful, as
will the C99 standard.

Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)
<http://www.dinkumware.com/refxc.html (C-library}
<http://gcc.gnu.org/onlinedocs/ (GNU docs)
<http://clc-wiki.net (C-info)

Some informative links about posting:
<http://members.fortunecity.com/nnqweb/ (newusers)
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/ (taming google)

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Jan 2 '07 #9

P: n/a

CBFalconer wrote:
"rhle.freak" wrote:
CBFalconer <cbfalco...@yahoo.comwrote:
"rhle.freak" wrote:
<snip>
alone. That is the point of quoting relevant matter. You would be
well advised to get a proper newsreader and access usenet directly
instead of through the flawed google interface. Also never use
<snip>

How do I access usenet directly?
For free ?

Regards,
Frodo B

Jan 2 '07 #10

P: n/a
Frodo Baggins wrote:
CBFalconer wrote:

<snip>
>alone. That is the point of quoting relevant matter. You would be
well advised to get a proper newsreader and access usenet directly
instead of through the flawed google interface. Also never use

<snip>

How do I access usenet directly? For free ?
Your ISP should provide that. Ask them, and they will also tell
you what the servers URL is. This is to be accessed by a news
reader, not a browser. If they don't provide a server they are not
a proper ISP, but you have the recourse of various free
newservers. Others exist, and people may chime in with their URLs.

Some free news servers
<http://www.teranew.com (free)
<http://www.newsfeeds.com/signup.htm (pay)

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Jan 2 '07 #11

P: n/a
CBFalconer wrote:

Some free news servers
<http://www.teranew.com (free)
<http://www.teranews.com/>
^
That 's' makes a lot of difference.


Brian
Jan 2 '07 #12

P: n/a
CBFalconer wrote:
Frodo Baggins wrote:
>CBFalconer wrote:

<snip>
>>alone. That is the point of quoting relevant matter. You would be
well advised to get a proper newsreader and access usenet directly
instead of through the flawed google interface. Also never use
<snip>

How do I access usenet directly? For free ?

Your ISP should provide that. Ask them, and they will also tell
you what the servers URL is. This is to be accessed by a news
reader, not a browser. If they don't provide a server they are not
a proper ISP, but you have the recourse of various free
newservers. Others exist, and people may chime in with their URLs.

Some free news servers
<http://www.teranew.com (free)
<http://www.newsfeeds.com/signup.htm (pay)
http://news.aioe.org

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Jan 2 '07 #13

P: n/a
On Tue, 2 Jan 2007 06:06:43 -0600, Frodo Baggins wrote
(in article <11**********************@n51g2000cwc.googlegroups .com>):
>
CBFalconer wrote:
>"rhle.freak" wrote:
>>CBFalconer <cbfalco...@yahoo.comwrote:
"rhle.freak" wrote:

<snip>
>alone. That is the point of quoting relevant matter. You would be
well advised to get a proper newsreader and access usenet directly
instead of through the flawed google interface. Also never use

<snip>

How do I access usenet directly?
It depends upon your ISP generally.
For free ?
That depends upon how you define free(). :-)

If your ISP bundles it into the price of your normal access fees, you
might consider it to be free in that context, as I do.

You'll probably need to look on the ISP's website support page (if any)
for things like "News server", or "NNTP".

It's usually something like:

news.ispdomainname.com

And may or may not require a user id and password for authentication.

As for suitable newsreaders, that depends upon your operating system.
Some examples of newsreaders are:

Windows: Gravity, SuperGravity, Agent, Thunderbird, Outlook Express
OS X: Hogwasher, MTNewswatcher, Thunderbird
Linux: A ton of them, including Thunderbird, slrn, trn, nn, xrn, and
many more.

In all almost all cases, the interface provided to Usenet is vastly
superior to that of Google.

--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Jan 2 '07 #14

P: n/a


On Jan 3, 1:42 am, Nelu <spamah...@gmail.comwrote:
CBFalconer wrote:
Frodo Baggins wrote:
CBFalconer wrote:
<snip>
http://news.aioe.org

thank you! i had the Thunderbird client for long ;was looking for a
news server .this is just fine!!

Jan 3 '07 #15

This discussion thread is closed

Replies have been disabled for this discussion.