What is this?

C

Cesar Rodas

I need because I want to write a file that need to be read in windows,
linux, freebsd and mobile handlers.

Writing structures directly is not portable. Not only may the total
size be different, but the representation of the parts may be
different too. For example, the byte order may be different.

Do it some other way, for example by writing functions to write each
part of the structure.[/QUOTE]

Good Idea Man!!! Thanks Richard I will do it
 
C

CBFalconer

Cesar said:
.... snip ...
typedef struct _foo { .... snip ...
} bar;
printf("%d\n", sizeof(bar));
WHY THE OUTPUT IS 1034? Is need to be 1024 + 4 + 4 + 1 = 1033

Another question for you: *why* do you need sizeof bar to be 1033.

I need because I want to write a file that need to be read in
windows, linux, freebsd and mobile handlers.

You are doomed. There is no way to ensure that that is even
readable on the system on which you compiled it, unless you use the
identical software (compiler, linker, etc.). Files consist of
sequences of bytes - use that fact.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
S

Spiros Bousbouras

Cesar said:
Keith said:
Cesar Rodas said:
typedef struct _foo
{
unsigned char lock;
long a;
long b;
unsigned char data[1024];
} bar; [snip]
printf("%d\n", sizeof(bar)); [snip]
WHY THE OUTPUT IS 1034? Is need to be 1024 + 4 + 4 + 1 = 1033

Another question for you: *why* do you need sizeof bar to be 1033.
I need because I want to write a file that need to be read in windows,
linux, freebsd and mobile handlers.

Unless you want the file to be as short as possible
I suggest that you come up with a text only representation
for the contents of the structure and write that to
the file.
 
K

Keith Thompson

CBFalconer said:
--
If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
a poor interface to usenet. There is no reason to assume your
readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>

Chuck, I suggest dropping the "Google is only a poor interface to
usenet" sentence. I agree with the statement for various reasons, but
I don't think it's relevant to the issue of quoting in followups.
Google Groups now lets you quote properly about as easily as any
ordinary newsreader. If Google users post followups with no quoted
material, it's because they explicitly deleted it.

The ease of seeing previous articles is arguably an advantage of the
Google interface; it's a problem only because it leads users to assume
that everyone else can see previous articles as easily as they can.
 
C

CBFalconer

Keith said:
Chuck, I suggest dropping the "Google is only a poor interface to
usenet" sentence. I agree with the statement for various reasons, but
I don't think it's relevant to the issue of quoting in followups.
Google Groups now lets you quote properly about as easily as any
ordinary newsreader. If Google users post followups with no quoted
material, it's because they explicitly deleted it.

The ease of seeing previous articles is arguably an advantage of the
Google interface; it's a problem only because it leads users to assume
that everyone else can see previous articles as easily as they can.

IMO one reason for maintaining it is that otherwise there is no
clue that google is not usenet.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
K

Keith Thompson

CBFalconer said:
IMO one reason for maintaining it is that otherwise there is no
clue that google is not usenet.

Perhaps "Google is not Usenet" (IMHO both should be capitalized) would
get that idea across.
 
C

CBFalconer

Keith said:
CBFalconer said:
Keith said:
[snip]
--
If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
a poor interface to usenet. There is no reason to assume your
readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>

Chuck, I suggest dropping the "Google is only a poor interface to
usenet" sentence. I agree with the statement for various reasons,
but I don't think it's relevant to the issue of quoting in followups.
Google Groups now lets you quote properly about as easily as any
ordinary newsreader. If Google users post followups with no quoted
material, it's because they explicitly deleted it.

The ease of seeing previous articles is arguably an advantage of the
Google interface; it's a problem only because it leads users to assume
that everyone else can see previous articles as easily as they can.

IMO one reason for maintaining it is that otherwise there is no
clue that google is not usenet.

Perhaps "Google is not Usenet" (IMHO both should be capitalized) would
get that idea across.

I'm listening :). How to include the fact that Usenet is the real
thing, and Google is only an interface, and make it obvious to
newbies, without too drastically exceeding the 4 line mark?

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
K

Keith Thompson

CBFalconer said:
Keith said:
CBFalconer said:
Keith Thompson wrote:
[snip]
--
If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
a poor interface to usenet. There is no reason to assume your
readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>

Chuck, I suggest dropping the "Google is only a poor interface to
usenet" sentence. I agree with the statement for various reasons,
but I don't think it's relevant to the issue of quoting in followups.
Google Groups now lets you quote properly about as easily as any
ordinary newsreader. If Google users post followups with no quoted
material, it's because they explicitly deleted it.

The ease of seeing previous articles is arguably an advantage of the
Google interface; it's a problem only because it leads users to assume
that everyone else can see previous articles as easily as they can.

IMO one reason for maintaining it is that otherwise there is no
clue that google is not usenet.

Perhaps "Google is not Usenet" (IMHO both should be capitalized) would
get that idea across.

I'm listening :). How to include the fact that Usenet is the real
thing, and Google is only an interface, and make it obvious to
newbies, without too drastically exceeding the 4 line mark?

Here's my suggestion:

If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
an interface to Usenet; it's not Usenet itself. Don't assume
your readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>

I reworded the second sentence, changed "There is no reason to assume"
to "Don't assume", and dropped the second URL, which only describes
how to work around a bug that no longer exists.
 
C

CBFalconer

Keith said:
.... snip ...

Here's my suggestion:

If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
an interface to Usenet; it's not Usenet itself. Don't assume
your readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>

I reworded the second sentence, changed "There is no reason to assume"
to "Don't assume", and dropped the second URL, which only describes
how to work around a bug that no longer exists.

I like it. Done! :)

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
D

Dave Thompson

On Mon, 22 Jan 2007 08:23:46 +0000, Richard Heathfield
Incidentally, like anything in standard headers, [CHAR_BIT]'s a read-only value;
changing it is of no more value to you than scribbling over the "amount
owing" part of the phone bill that drops through your door.

<OT fart_type=old>
Although back in the late '50s and early '60s, when (at least in the
US) only a few of the largest organizations were using computers for
business operations, they often sent out a (pre)punched card in your
bill and expected/required you to return it with payment, and
modifying that card with a keypunch, or a small knife and a very
steady hand, could produce, er, interesting results. Although not as
immediately and gratifyingly as whistling on a trunk call. <G>

- David.Thompson1 at worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top