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

malloc + 4??

P: n/a
http://www.yep-mm.com/res/soCrypt.c

I have 2 malloc's in my program, and when I write the contents of them to
the screen or to a file, there aren addition 4 characters.

As far as I can tell, both the code to register the malloc and to write
information into the malloc is solid. Why then ismy program returning an
additional 4 characters?

register malloc 1:
line 192

register malloc 2:
line 214

write to malloc 1:
line 200 - 205

write to malloc 2:
line 221 - 225

display malloc 2:
line 157

write malloc 2:
line 251

Here's how you execute the program:

socrypt.exe /e :i input.txt :o output.txt :A keya.txt :B keyb.txt :k
keyout.txt

**note that the input, keya, and keyb files must exist or the program will
return an error code.

If you write a text string into the input.txt file, it will write the same
string into the output.txt file plus an addition 4 characters.

The 1024 char random 'masterkey' is also written out to the keyout.txt file
with an addition 4 characters.

Why is this happening? I'm totally baffled and have spent days trying to
figure this out.
Nov 14 '05 #1
Share this Question
Share on Google+
144 Replies


P: n/a
Kevin Torr <ke*******@hotmail.com> scribbled the following:
http://www.yep-mm.com/res/soCrypt.c I have 2 malloc's in my program, and when I write the contents of them to
the screen or to a file, there aren addition 4 characters. As far as I can tell, both the code to register the malloc and to write
information into the malloc is solid. Why then ismy program returning an
additional 4 characters?


The C standard says that malloc is allowed to allocate more memory than
requested.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It sure is cool having money and chicks."
- Beavis and Butt-head
Nov 14 '05 #2

P: n/a
In article <40***********************@news.syd.swiftdsl.com.a u>
Kevin Torr <ke*******@hotmail.com> writes:
http://www.yep-mm.com/res/soCrypt.c
In general, it is better to post the actual problematic code
(preferably after shrinking it down to a "problematic nub", as it
were), but a URL reference can work if the one reading netnews
bothers to follow the link. :-)
I have 2 malloc's in my program, and when I write the contents of them to
the screen or to a file, there aren addition 4 characters. As far as I can tell, both the code to register the malloc and to write
information into the malloc is solid. Why then ismy program returning an
additional 4 characters?
It is not quite as solid as one might hope, although the problem
has nothing to do with malloc() per se. Here are excerpts from the
code (quoted with ">" as usual, although I had to insert the markers
myself):
// soCrypt 1.0

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// #include <md5.h>
OK so far, although //-comments are specific to C99. You have
included necessary headers, so you will not need to cast malloc()'s
return value.
// Global variables

int statCode = 0; // Status code
int mode; // Mode variable (1 = enc, 2 = dec)
int i; // Looper variable
int inSize = 0; // Input filesize
int intRand; // Random int
char tmp_char; // Temporary char
Many of these should not be file-scope external-linkage ("global")
variables, although this is mostly a style issue (at least in a
program this small).

Note that tmp_char has type "char"; on a typical PowerPC, it would
hold values between 0 and 255 inclusive, because there plain "char"
is unsigned. The variable inSize is a plain (signed) int and has
at least the range [-32767..+32767] (although most systems, today,
have an even wider range, about +/- 2 billion).
char *pMasterKey; // Malloc pointer to the master key
char *pInputData; // Malloc pointer to the input data
Skipping forward, we have:
// Reads the input file

int readFile()
{

rewind(inFile);
i = 0;
tmp_char = 'a';
while(tmp_char != EOF)
{
i++;
tmp_char = getc(inFile);
}
inSize = i-1;
This loop tries to count the size of the file by calling getc()
until getc() returns EOF. The problem is that EOF is some sort of
negative number -- typically -1, but perhaps even -2000 or some
such -- and tmp_char is a plain "char". If tmp_char is unable to
hold the value EOF, which will be true if plain char is unsigned
or if EOF is less than CHAR_MIN (e.g., -2000 vs -128 for instance),
the loop will never terminate.

This is why getc() returns a value of type "int" in the first place,
so that it can return all possible "char"s (having first converted
any negative ones to positive values as if via "unsigned char"),
yet also return the special marker value EOF. If you want to store
both "any valid character" *and* EOF, you need something with a
wider range than "any valid character".

Of course, there is really no need for tmp_char at all, nor for
correcting for the off-by-one error produced by counting inside
the loop *before* getting a character. Just change the loop to,
e.g.:

while (getc(inFile) != EOF)
i++;

Combine this with using local variables, and perhaps a "for"
loop to collect up the initialization, test, and increment, we
might get something like:

int readFile() {
int i;

rewind(inFile);
for (i = 0; getc(inFile) != EOF; i++)
continue;
inSize = i;

(although I would also pass the "FILE *" parameter to readFile,
and probably return the allocated memory rather than an "int"
status code).
if ((pInputData = (char *)malloc(inSize * sizeof(char))) == NULL)
{
statCode = 8;
return(statCode);
}
This is OK in and of itself, but there are two important things to
note. First, the cast is not required. It does no harm, but also
does no help. It is a bit like saying "tmp_char = (char)getc(inFile)",
when tmp_char is already a char. The assignment will do the
conversion for you -- and you do not use a cast below, so why use
one above?

Second, and the actual source of the observed problem later, note
that this allocates just enough space to store all the characters
you intend to read from the file.

Consider the C string "hello world". How many characters are in
it? How many characters does it take to *store* it? Why, after:

char hello[] = "hello world";

is there a difference of 1 between "sizeof hello" and "strlen(hello")?

The answer is: because C strings require a '\0' marker after all
their valid "char"s. The array hello[] has size 12, not size 11,
because it stores the 11 "char"s that make up the two words and
the blank, and then one more to store the '\0' marker.

The variable inSize might (for instance) hold 5 if the file contents
are "word\n" (perhaps followed by an EOF marker, if your system
actually uses such markers in files), but if you want to use the
sequence {'w', 'o', 'r', 'd', '\n'} as a C string, you need *six*
bytes: {'w', 'o', 'r', 'd', '\n', '\0'}.

Of course, there is no requirement that you treat the file as
a C string -- that part is up to you. In any case:
rewind(inFile);
i = 0;
tmp_char = 'a';
while (i < inSize)
{
tmp_char = getc(inFile);
*(pInputData + i) = tmp_char;
i++;
}
return 0;
}
There is nothing *wrong* here, but the code can be simplified
enormously. First, tmp_char is never inspected without first
calling getc(), so there is no need to "prime the pump" -- the
loop tests "i < inSize". Second, there is no need for tmp_char
at all; you can just assign the value from getc() directly into
pInputData[i]. Third, you can write pInputData[i] that way,
rather than using the equivalent unary-"*" sequence, and again
perhaps a "for" loop might express the whole sequence better:

rewind(inFile);
for (i = 0; i < inSize; i++)
pInputData[i] = getc(inFile);
return 0;
}

Skipping forward to the source of the observed problem:
// Writes the output file

int writeFile()
{
fputs(pInputData, outFile);
fputs(pMasterKey, keyOut);
return 0;
}


The fputs() function demands a string -- a sequence of "char"s
ending with a '\0' termination marker. pInputData points to the
first of a sequence of "char"s, but not one that has the "stop here
at the \0" mark in it.

Without making any other changes, you can either allocate one extra
byte and put in the '\0', or you can change the method you use to
write the final output. The two simply have to agree as to whether
pInputData (and pMasterKey -- but I did not even look at that code)
is a counted string (length inSize, for pInputData) or a C-style
'\0'-terminated string.

Note that a '\0'-terminated string cannot *contain* a '\0', so if
you want (for whatever reason) to allow embedded '\0' bytes, you
will have to choose the counted-string method. You could write
out a counted string with a loop:

int writeFile() {
int i;

for (i = 0; i < inSize; i++)
putc(pInputData[i], outFile);
/* optional:
if (fflush(outFile) || ferror(outFile))
... handle output failure ... */
/* and repeat for pMasterKey */
}

or you can use fwrite(), which essentially does the loop for you.
(Note that fwrite() works just fine with ordinary text, and in
fact, fputs() can be implemented internally as:

int fputs(char *s, FILE *stream) {
size_t len = strlen(s);

return fwrite(s, 1, len, stream) == len ? 0 : EOF;
}

Here strlen() looks for, but does not count, the terminating '\0',
then fwrite() loops over all the valid bytes, putc()ing each one
to the stream. The only remaining problem is that the return value
from fwrite() does not match that from fputs(), so it has to be
converted.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #3

P: n/a
"Chris Torek" <no****@torek.net> wrote in message
news:c4*********@news2.newsguy.com...
In article <40***********************@news.syd.swiftdsl.com.a u>
Kevin Torr <ke*******@hotmail.com> writes:
http://www.yep-mm.com/res/soCrypt.c


In general, it is better to post the actual problematic code
(preferably after shrinking it down to a "problematic nub", as it
were), but a URL reference can work if the one reading netnews
bothers to follow the link. :-)
I have 2 malloc's in my program, and when I write the contents of them to
the screen or to a file, there aren addition 4 characters.

As far as I can tell, both the code to register the malloc and to write
information into the malloc is solid. Why then ismy program returning an
additional 4 characters?


It is not quite as solid as one might hope, although the problem
has nothing to do with malloc() per se. Here are excerpts from the
code (quoted with ">" as usual, although I had to insert the markers
myself):
// soCrypt 1.0

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// #include <md5.h>


OK so far, although //-comments are specific to C99. You have
included necessary headers, so you will not need to cast malloc()'s
return value.
// Global variables

int statCode = 0; // Status code
int mode; // Mode variable (1 = enc, 2 = dec)
int i; // Looper variable
int inSize = 0; // Input filesize
int intRand; // Random int
char tmp_char; // Temporary char


Many of these should not be file-scope external-linkage ("global")
variables, although this is mostly a style issue (at least in a
program this small).

Note that tmp_char has type "char"; on a typical PowerPC, it would
hold values between 0 and 255 inclusive, because there plain "char"
is unsigned. The variable inSize is a plain (signed) int and has
at least the range [-32767..+32767] (although most systems, today,
have an even wider range, about +/- 2 billion).
char *pMasterKey; // Malloc pointer to the master key
char *pInputData; // Malloc pointer to the input data


Skipping forward, we have:
// Reads the input file

int readFile()
{

rewind(inFile);
i = 0;
tmp_char = 'a';
while(tmp_char != EOF)
{
i++;
tmp_char = getc(inFile);
}
inSize = i-1;


This loop tries to count the size of the file by calling getc()
until getc() returns EOF. The problem is that EOF is some sort of
negative number -- typically -1, but perhaps even -2000 or some
such -- and tmp_char is a plain "char". If tmp_char is unable to
hold the value EOF, which will be true if plain char is unsigned
or if EOF is less than CHAR_MIN (e.g., -2000 vs -128 for instance),
the loop will never terminate.

This is why getc() returns a value of type "int" in the first place,
so that it can return all possible "char"s (having first converted
any negative ones to positive values as if via "unsigned char"),
yet also return the special marker value EOF. If you want to store
both "any valid character" *and* EOF, you need something with a
wider range than "any valid character".

Of course, there is really no need for tmp_char at all, nor for
correcting for the off-by-one error produced by counting inside
the loop *before* getting a character. Just change the loop to,
e.g.:

while (getc(inFile) != EOF)
i++;

Combine this with using local variables, and perhaps a "for"
loop to collect up the initialization, test, and increment, we
might get something like:

int readFile() {
int i;

rewind(inFile);
for (i = 0; getc(inFile) != EOF; i++)
continue;
inSize = i;

(although I would also pass the "FILE *" parameter to readFile,
and probably return the allocated memory rather than an "int"
status code).
if ((pInputData = (char *)malloc(inSize * sizeof(char))) == NULL)
{
statCode = 8;
return(statCode);
}


This is OK in and of itself, but there are two important things to
note. First, the cast is not required. It does no harm, but also
does no help. It is a bit like saying "tmp_char = (char)getc(inFile)",
when tmp_char is already a char. The assignment will do the
conversion for you -- and you do not use a cast below, so why use
one above?

Second, and the actual source of the observed problem later, note
that this allocates just enough space to store all the characters
you intend to read from the file.

Consider the C string "hello world". How many characters are in
it? How many characters does it take to *store* it? Why, after:

char hello[] = "hello world";

is there a difference of 1 between "sizeof hello" and "strlen(hello")?

The answer is: because C strings require a '\0' marker after all
their valid "char"s. The array hello[] has size 12, not size 11,
because it stores the 11 "char"s that make up the two words and
the blank, and then one more to store the '\0' marker.

The variable inSize might (for instance) hold 5 if the file contents
are "word\n" (perhaps followed by an EOF marker, if your system
actually uses such markers in files), but if you want to use the
sequence {'w', 'o', 'r', 'd', '\n'} as a C string, you need *six*
bytes: {'w', 'o', 'r', 'd', '\n', '\0'}.

Of course, there is no requirement that you treat the file as
a C string -- that part is up to you. In any case:
rewind(inFile);
i = 0;
tmp_char = 'a';
while (i < inSize)
{
tmp_char = getc(inFile);
*(pInputData + i) = tmp_char;
i++;
}
return 0;
}


There is nothing *wrong* here, but the code can be simplified
enormously. First, tmp_char is never inspected without first
calling getc(), so there is no need to "prime the pump" -- the
loop tests "i < inSize". Second, there is no need for tmp_char
at all; you can just assign the value from getc() directly into
pInputData[i]. Third, you can write pInputData[i] that way,
rather than using the equivalent unary-"*" sequence, and again
perhaps a "for" loop might express the whole sequence better:

rewind(inFile);
for (i = 0; i < inSize; i++)
pInputData[i] = getc(inFile);
return 0;
}

Skipping forward to the source of the observed problem:
// Writes the output file

int writeFile()
{
fputs(pInputData, outFile);
fputs(pMasterKey, keyOut);
return 0;
}


The fputs() function demands a string -- a sequence of "char"s
ending with a '\0' termination marker. pInputData points to the
first of a sequence of "char"s, but not one that has the "stop here
at the \0" mark in it.

Without making any other changes, you can either allocate one extra
byte and put in the '\0', or you can change the method you use to
write the final output. The two simply have to agree as to whether
pInputData (and pMasterKey -- but I did not even look at that code)
is a counted string (length inSize, for pInputData) or a C-style
'\0'-terminated string.

Note that a '\0'-terminated string cannot *contain* a '\0', so if
you want (for whatever reason) to allow embedded '\0' bytes, you
will have to choose the counted-string method. You could write
out a counted string with a loop:

int writeFile() {
int i;

for (i = 0; i < inSize; i++)
putc(pInputData[i], outFile);
/* optional:
if (fflush(outFile) || ferror(outFile))
... handle output failure ... */
/* and repeat for pMasterKey */
}

or you can use fwrite(), which essentially does the loop for you.
(Note that fwrite() works just fine with ordinary text, and in
fact, fputs() can be implemented internally as:

int fputs(char *s, FILE *stream) {
size_t len = strlen(s);

return fwrite(s, 1, len, stream) == len ? 0 : EOF;
}

Here strlen() looks for, but does not count, the terminating '\0',
then fwrite() loops over all the valid bytes, putc()ing each one
to the stream. The only remaining problem is that the return value
from fwrite() does not match that from fputs(), so it has to be
converted.)


Wow, thanks for all that. I will have to get my head around it all.

So when do I need not cast mallocs? when I include a header? which header?
Or are you saying that I don't need to cast a malloc if I've already defined
the pointer as a data type?
What would be a possible bad thing if I did cast a malloc when I didn't need
to? Is there something that could go wrong or is it just redundant?
Nov 14 '05 #4

P: n/a
Kevin Torr wrote:
Wow, thanks for all that. I will have to get my head around it all.

So when do I need not cast mallocs?
Never.
when I include a header? which header?


You have to include stdlib.h when you use malloc (or provide the
prototype of malloc() yourself, but i can't imagine why you would prefer
that)
--
John Tsiombikas (Nuclear / the Lab)
nu*****@siggraph.org
http://thelab.demoscene.gr/nuclear/
Nov 14 '05 #5

P: n/a
"John Tsiombikas (Nuclear / the Lab)" <nu*****@siggraph.org> writes:
Kevin Torr wrote:
Wow, thanks for all that. I will have to get my head around it all.
So when do I need not cast mallocs?


Never.


Too many negatives for me. Simply stated, the return value of
malloc() rarely needs to be cast.
when I include a header? which header?


You have to include stdlib.h when you use malloc (or provide the
prototype of malloc() yourself, but i can't imagine why you would
prefer that)


Providing a prototype of malloc() yourself is arguably not valid
practice based on this sentence from the standard, section 7.1.4:

2 Provided that a library function can be declared without
reference to any type defined in a header, it is also
permissible to declare the function and use it without
including its associated header.

You can certainly declare malloc() without a type defined in a
header, but giving a prototype requires using size_t. It's
better just to use the header.
--
"Some people *are* arrogant, and others read the FAQ."
--Chris Dollin
Nov 14 '05 #6

P: n/a
John Tsiombikas (Nuclear / the Lab) wrote:
Kevin Torr wrote:
Wow, thanks for all that. I will have to get my head around it all.

So when do I need not cast mallocs?

Never.


Actually he *always* need not cast mallocs.
What he need never do is cast mallocs.
Nov 14 '05 #7

P: n/a
In <40*********************@news.club-internet.fr> Richard Delorme <ab****@nospam.fr> writes:
Dan Pop a écrit :
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
it for richness of vocabulary). I've heard that English is the only
language in which spelling bees are held (contests in which the object
is to correctly spell words after hearing them spoken).
There are such contests for French, too. The winners are usually NOT
native French speakers.


That's not true. The most popular contest is "la dictée de Pivot" also
known as "Les Dicos d'or" and the winners are usually French, but there
is a category for non native French speakers.


Obviously, a non-native French speaker cannot win at the category reserved
to native French speakers :-) I was talking about open contests.
BTW, the average native French speaker can speak French grammatically
correct, but cannot write French grammatically correct. For most verbs,
several tenses and forms are pronounced identically, but written
differently. Since they learned speaking instinctively, get it right
when speaking is trivial, while getting it right when writing requires
a solid understanding of the French grammar (otherwise, it's trivially
easy to mix up, e.g. the infinitive and past participle of most regular
verbs).


Although your last example is a common mistake, it's very easy to avoid
it for a native french speaker: just replace the verb by another one
(usually "prendre") and its pronunciation discriminates between the
infinitive and the past participle.


It doesn't matter how easy it is to avoid, what really matters is that it
is a *very* common mistake. If the written form sounds correctly, far too
many people don't bother to make the slightest effort to check that it is
the correct form.
The most difficult part of the
French grammar is the agreement of the adjectives and past participles.
In some cases, it only depends on the order of the words in the sentence.
Besides French grammar, spelling French is difficult because of the many
ways (not as much as English, though) to write the same sound and
because of the presence of mute letters (much more than English), e.g.
"saint", "sain", "sein", "seing", "ceint", "cinq" all share an identical
pronunciation but a different meaning.


It's not that difficult, once you get the hang of it. As a non-native
French speaker I was able to correctly spell words I was hearing for the
first time. And the context helps a lot when disambiguating between
words with identical or near identical pronunciation, just like
in English.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #8

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El 8 Apr 2004 08:33:51 GMT, Joona I Palaste escribió:
People here might know next to nothing about Finnish, but like it's
been said, Finnish is pronounced pretty much like it's written. I have
studied (at least cursorily) many languages, and I truly believe Finnish
gets the closest to a 1-1 correspondence between written glyphs and
spoken sounds.


I'm spanish, and I have to say that spanish is *exactly* pronounced as
it is written, except for "h" letter, that is not pronounced at all.

- --
Alberto Giménez, SimManiac en el IRC
http://www.almorranasozial.es.vg
GNU/Linux Debian Woody 3.0 GnuPG ID: 0x3BAABDE1
Linux registered user #290801
Windows 98 no se cuelg·$%&/# NO CARRIER
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAe9Qa0keCtzuqveERAgKPAJwN/1O1uFE2KwfXP8eOD+K++zQNMgCfQk3O
ZBo2H5wau7YLtS3ZmC+LUfU=
=olv1
-----END PGP SIGNATURE-----
Nov 14 '05 #9

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El Thu, 8 Apr 2004 11:50:17 -0400 (EDT), Arthur J. O'Dwyer escribió:
in Spanish pronunciation are what happens to 'c[aou]' versus 'c[ei]' and
'gu[ao]' versus 'gu[ei]'. But I'm a little out of it, so maybe I missed


yes, i forgot that in my last post :)
hm, i could add "r" versus "rr", but i don't think it is a
pronounciation "peculiarity", and with qu[ei], where u is not pronounced
(in spanish no word is written with "qua" or "quo") :)

- --
Alberto Giménez, SimManiac en el IRC
http://www.almorranasozial.es.vg
GNU/Linux Debian Woody 3.0 GnuPG ID: 0x3BAABDE1
Linux registered user #290801
Windows 98 no se cuelg·$%&/# NO CARRIER
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAe9UD0keCtzuqveERAqFiAJ9d03tx0rF+ewWTZL2vwM b7y1HPfwCdEXln
yjzYZb/1TY3ctvowwN/FqQI=
=qK14
-----END PGP SIGNATURE-----
Nov 14 '05 #10

P: n/a
Martin Ambuhl wrote:

John Tsiombikas (Nuclear / the Lab) wrote:
Kevin Torr wrote:
So when do I need not cast mallocs?


Never.

Actually he *always* need not cast mallocs.
What he need never do is cast mallocs.


Hm, it seems I missed the *not* in there, for some obscure reason I
thought that he asked "So when do I need to cast mallocs?". :)))

--
John Tsiombikas (Nuclear / the Lab)
nu*****@siggraph.org
http://thelab.demoscene.gr/nuclear/
Nov 14 '05 #11

P: n/a
Alberto Giménez <al****@teleline.es> scribbled the following:
El 8 Apr 2004 08:33:51 GMT, Joona I Palaste escribió:
People here might know next to nothing about Finnish, but like it's
been said, Finnish is pronounced pretty much like it's written. I have
studied (at least cursorily) many languages, and I truly believe Finnish
gets the closest to a 1-1 correspondence between written glyphs and
spoken sounds.
I'm spanish, and I have to say that spanish is *exactly* pronounced as
it is written, except for "h" letter, that is not pronounced at all.


Close, but no cigar. Some minor points: Why is the 'u' in "qu"
pronounced differently than the normal 'u'? (For example "una
quilogramme".) Why do 'l' by itself and "ll" have separate
pronunciations? (I don't know how the "ll" is pronounced correctly,
but I think I know it's *not* pronounced as two 'l' sounds.)
Why can 'y' be both a consonant (like in "yo") and a vowel (like in
"hay")?
I suppose 'j' in Spanish is always pronounced like 'h' in English.
Fair enough, but seeing as it's pronounced in Finnish like the
consonant 'y' in English and Spanish, it strikes me as a little weird.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It was, er, quite bookish."
- Horace Boothroyd
Nov 14 '05 #12

P: n/a
Ben Pfaff wrote:
when I include a header? which header?


You have to include stdlib.h when you use malloc (or provide the
prototype of malloc() yourself, but i can't imagine why you would
prefer to do that)


Providing a prototype of malloc() yourself is arguably not valid
practice based on this sentence from the standard, section 7.1.4:

2 Provided that a library function can be declared without
reference to any type defined in a header, it is also
permissible to declare the function and use it without
including its associated header.

You can certainly declare malloc() without a type defined in a
header, but giving a prototype requires using size_t. It's
better just to use the header.


So are you saying that you can't do the following?

#include <stddef.h> /* for size_t */
void *malloc(size_t);

this is providing a prototype for malloc, without including stdlib.h and
yes ofcourse it's better to just use the header, I just added that
comment for completeness, if I may quote myself :)
"or provide the prototype of malloc() yourself, but i can't imagine why
you would prefer to do that"

--
John Tsiombikas (Nuclear / the Lab)
nu*****@siggraph.org
http://thelab.demoscene.gr/nuclear/
Nov 14 '05 #13

P: n/a
"John Tsiombikas (Nuclear / the Lab)" <nu*****@siggraph.org> writes:
Ben Pfaff wrote:
when I include a header? which header?

You have to include stdlib.h when you use malloc (or provide the
prototype of malloc() yourself, but i can't imagine why you would
prefer to do that)

Providing a prototype of malloc() yourself is arguably not valid
practice based on this sentence from the standard, section 7.1.4:
2 Provided that a library function can be declared without
reference to any type defined in a header, it is also
permissible to declare the function and use it without
including its associated header.
You can certainly declare malloc() without a type defined in a
header, but giving a prototype requires using size_t. It's
better just to use the header.


So are you saying that you can't do the following?

#include <stddef.h> /* for size_t */
void *malloc(size_t);

this is providing a prototype for malloc, without including stdlib.h


You got size_t from a header, which seems to fall afoul of the
spirit of the provision above. Whether it is actually undefined
behavior would be better judged in comp.std.c. But it is better
in any case to simply include <stdlib.h>.
--
"We put [the best] Assembler programmers in a little glass case in the hallway
near the Exit sign. The sign on the case says, `In case of optimization
problem, break glass.' Meanwhile, the problem solvers are busy doing their
work in languages most appropriate to the job at hand." --Richard Riehle
Nov 14 '05 #14

P: n/a

On Tue, 13 Apr 2004, Joona I Palaste wrote:

Alberto Giménez <al****@teleline.es> scribbled the following:
El 8 Apr 2004 08:33:51 GMT, Joona I Palaste escribió:
People here might know next to nothing about Finnish, but like it's
been said, Finnish is pronounced pretty much like it's written. I have
studied (at least cursorily) many languages, and I truly believe Finnish
gets the closest to a 1-1 correspondence between written glyphs and
spoken sounds.
I'm spanish, and I have to say that spanish is *exactly* pronounced as
it is written, except for "h" letter, that is not pronounced at all.


Close, but no cigar. Some minor points: Why is the 'u' in "qu"
pronounced differently than the normal 'u'? (For example "una
quilogramme".)


Is this correct in some Spanish dialect with which I'm unfamiliar?
I thought the word for "kilogram" in Spanish was... well.. "kilogramo."
Certainly the "gramme" ending in Joona's word isn't Spanish; Spanish
doesn't double consonants. Looks like a weird Ibero-British hybrid
to me. :)
(After Googling: is this something like Catalan?)
Why do 'l' by itself and "ll" have separate
pronunciations? (I don't know how the "ll" is pronounced correctly,
but I think I know it's *not* pronounced as two 'l' sounds.)
The two-'l' letter is the "elle" (pronounced roughly like the
English letter "A": "A-yay"). In words, it's pronounced like the
English 'y': "me llamo" -> "may yamo". And perfectly regularly so.

Spanish used to consider both the 'll' and the 'ch' to be letters
in their own right, along with the enye (n+tilde; sorry, not in my
encoding). But IIRC recently the Spanish people in charge of the
"official" language decided to give up the separate letters for 'ch'
and 'll', and now you'll find "llama" in between "liviano" and "local"
in the dictionary.
Why can 'y' be both a consonant (like in "yo") and a vowel (like in
"hay")?
I'd say, because Spanish doesn't consider 'y' either a consonant or
a vowel, just as in English. The 'y' sound is kind of in-between.
In any event, the 'y' in "yo" isn't really acting like a consonant:
it's just adding the extra "ee" sort of sound. Just like it's doing
in "hay," which without the 'y' would be pronounced "ahh." With the
'y', it's pronounced "ahh-ee," but run together into "ai."

[It's weird trying to write down phonetic descriptions in "English"
syllables, when we're talking about a *more* phonetic language in the
first place, and I know English isn't your first language in the second
place. ;) ]
I suppose 'j' in Spanish is always pronounced like 'h' in English.
Correct, AFAIK.
Fair enough, but seeing as it's pronounced in Finnish like the
consonant 'y' in English and Spanish, it strikes me as a little weird.


Sounds to me like *Finnish* is the weird one. ;-))

-Arthur

Nov 14 '05 #15

P: n/a
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:c5**********@oravannahka.helsinki.fi...
Alberto Giménez <al****@teleline.es> scribbled the following:
I'm spanish, and I have to say that spanish is *exactly* pronounced as
it is written, except for "h" letter, that is not pronounced at all.
Close, but no cigar. Some minor points: Why is the 'u' in "qu"
pronounced differently than the normal 'u'? (For example "una
quilogramme".) Why do 'l' by itself and "ll" have separate
pronunciations?


'ch', 'll', and 'rr' are considered separate letters in the Spanish alphabet
with their own pronunciation, not combinations of two letters. For example,
the word "churro" has four letters and should come _after_ "cuba" in sort
order. Arguably, 'qu' should be another (composite) letter as well,
especially since 'q' isn't used on its own.

"kilogramo" or just "kilo" are the words I know in Spanish, by the way.
However, since 'k' is not in the Spanish alphabet, I presume the correct
spelling is "quilogramo". The -mme ending in your spelling looks French,
not Spanish.
(I don't know how the "ll" is pronounced correctly, but I think I know it's *not* pronounced as two 'l' sounds.)
The exact pronunciation of 'll' depends on dialect; most pronounce it as the
French do, with a 'y' sound.
Why can 'y' be both a consonant (like in "yo") and a vowel (like in
"hay")?
For every word I can think of, you get the correct pronunciation (for most
dialects) if you replace 'y' with 'i' -- in fact the name of 'y' is "i
griega", or "greek i". Of course, there are dialects where the consonant
sound of 'y' is very different, but that's an aberration.
I suppose 'j' in Spanish is always pronounced like 'h' in English.
Fair enough, but seeing as it's pronounced in Finnish like the
consonant 'y' in English and Spanish, it strikes me as a little weird.


When switching between English, Spanish, and French, the 'j' probably trips
me up more than anything else since it has totally different sounds in each.
Most other letters sound the same in at least two of them.

S

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin

Nov 14 '05 #16

P: n/a
Alberto Giménez wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El 8 Apr 2004 08:33:51 GMT, Joona I Palaste escribió:
People here might know next to nothing about Finnish, but like it's
been said, Finnish is pronounced pretty much like it's written. I have
studied (at least cursorily) many languages, and I truly believe Finnish
gets the closest to a 1-1 correspondence between written glyphs and
spoken sounds.

I'm spanish, and I have to say that spanish is *exactly* pronounced as
it is written, except for "h" letter, that is not pronounced at all.

With all due respect, Spain (Iberia) has four (more?) regions with
their own languages. Castille, Andalusia, Catalonia, Basque, etc.
Which of these are you talking about? Then there is Central and most
of South America. Do you suppose these people write and pronounce
Spanish the same, or even like you do? How do you pronounce
'tortilla' where you live, and what would you get if you ordered it?
How would you pronounce it in Mexico and what would you get?

Phonetic spelling is tedious so bear with me if you can.
In Spain it is 'tor-TILL-ya' and is very much like an omelette.
In Mexico it is 'tor-TEE-ya' and is a dry corn pancake.

--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #17

P: n/a
"Kevin Torr" <ke*******@hotmail.com> writes:
"Chris Torek" <no****@torek.net> wrote in message
news:c4*********@news2.newsguy.com... [...] Wow, thanks for all that. I will have to get my head around it all.

So when do I need not cast mallocs? when I include a header? which header?
Or are you saying that I don't need to cast a malloc if I've already defined
the pointer as a data type?
What would be a possible bad thing if I did cast a malloc when I didn't need
to? Is there something that could go wrong or is it just redundant?


Speaking of redundant, you just re-posted over 230 lines of Chris
Torek's text. Please limit quoted material to what's relevant to your
reply.

To answer your question, if you're going to use malloc() you should
always include <stdlib.h>, and you should never cast the result.

Casting the result masks possible errors. It can eliminate the
warning message you'll get if you've forgotten to include <stdlib.h>,
but only because you're lying to the compiler. It's like eliminating
a warning light on your dashboard by unscrewing the light bulb rather
than by fixing the problem it's trying to tell you about.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #18

P: n/a
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:
Alberto Giménez <al****@teleline.es> scribbled:
Joona I Palaste escribió:
People here might know next to nothing about Finnish, but like it's
been said, Finnish is pronounced pretty much like it's written. I have
studied (at least cursorily) many languages, and I truly believe Finnish
gets the closest to a 1-1 correspondence between written glyphs and
spoken sounds.

I must agree with you here. One can make a fairly good guess at a
Finnish word's pronunciation by interpreting its letters as letters
in the International Phonetic Association's alphabet
(http://www.arts.gla.ac.uk/IPA/ipa.html)
I'm spanish, and I have to say that spanish is *exactly* pronounced as
it is written, except for "h" letter, that is not pronounced at all.
Close, but no cigar. Some minor points: Why is the 'u' in "qu"
pronounced differently than the normal 'u'? (For example "una
quilogramme".) Why do 'l' by itself and "ll" have separate
pronunciations? (I don't know how the "ll" is pronounced correctly,
but I think I know it's *not* pronounced as two 'l' sounds.)
Why can 'y' be both a consonant (like in "yo") and a vowel (like in
"hay")?


Another minor point that comes to mind: 'c' in "capitan" vs. 'c'
in "Barcelona". I'm no authority on Spanish pronunciation but I
believe these two are different.
I suppose 'j' in Spanish is always pronounced like 'h' in English.


In fact 'j' in Spanish is a consonant that does not occur in English
(it does occur in German, and most other european languages).
English speakers say it as 'h' because it is the closest-matching
English sound. In fact it is common for allophones (sounds which differ
audibly but are interchangeable in pronunciation without affecting
the word) to be "heard" as only one sound, by people who have not put
effort into discerning the difference. Another example is English 'th'
in "thick" vs. "then".

At any rate this isn't a "problem" , I interpret "pronounced as it
is written" to mean "the same letter has the same pronunciation,
regardless of its context".
Nov 14 '05 #19

P: n/a
"Chris Torek" <no****@torek.net> wrote in message
(although most systems, today,
have an even wider range, about +/- 2 billion).


Only, however, if you live in the US. (Or France).
Nov 14 '05 #20

P: n/a
Old Wolf <ol*****@inspire.net.nz> scribbled the following:
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:
Alberto Giménez <al****@teleline.es> scribbled:
Joona I Palaste escribió:
>> People here might know next to nothing about Finnish, but like it's
>> been said, Finnish is pronounced pretty much like it's written. I have
>> studied (at least cursorily) many languages, and I truly believe Finnish
>> gets the closest to a 1-1 correspondence between written glyphs and
>> spoken sounds.
I must agree with you here. One can make a fairly good guess at a
Finnish word's pronunciation by interpreting its letters as letters
in the International Phonetic Association's alphabet
(http://www.arts.gla.ac.uk/IPA/ipa.html)
In fact, I once had a cursory glance at ASCII-IPA to see how the
Finnish word "yhdysvaltalainen"'s (USAn) pronunication is written in
ASCII-IPA. Turns out it's /yhdysvaltalainen/.
> I'm spanish, and I have to say that spanish is *exactly* pronounced as
> it is written, except for "h" letter, that is not pronounced at all.


Close, but no cigar. Some minor points: Why is the 'u' in "qu"
pronounced differently than the normal 'u'? (For example "una
quilogramme".) Why do 'l' by itself and "ll" have separate
pronunciations? (I don't know how the "ll" is pronounced correctly,
but I think I know it's *not* pronounced as two 'l' sounds.)
Why can 'y' be both a consonant (like in "yo") and a vowel (like in
"hay")? Another minor point that comes to mind: 'c' in "capitan" vs. 'c'
in "Barcelona". I'm no authority on Spanish pronunciation but I
believe these two are different.
Oh yes, I didn't think about that one.
I suppose 'j' in Spanish is always pronounced like 'h' in English.

In fact 'j' in Spanish is a consonant that does not occur in English
(it does occur in German, and most other european languages).
English speakers say it as 'h' because it is the closest-matching
English sound. In fact it is common for allophones (sounds which differ
audibly but are interchangeable in pronunciation without affecting
the word) to be "heard" as only one sound, by people who have not put
effort into discerning the difference. Another example is English 'th'
in "thick" vs. "then". At any rate this isn't a "problem" , I interpret "pronounced as it
is written" to mean "the same letter has the same pronunciation,
regardless of its context".


Yes, and this means that neither Spanish nor English is "pronounced
as written". Finnish is *almost* - the 'n' in "ng" or "nk" is not
pronounced like a normal 'n'. Otherwise it's "pronounced as written".

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Holy Banana of this, Sacred Coconut of that, Magic Axolotl of the other."
- Guardian in "Jinxter"
Nov 14 '05 #21

P: n/a
In <40***********************@news.syd.swiftdsl.com.a u> "Kevin Torr" <ke*******@hotmail.com> writes:
http://www.yep-mm.com/res/soCrypt.c

I have 2 malloc's in my program, and when I write the contents of them to
the screen or to a file, there aren addition 4 characters.

As far as I can tell, both the code to register the malloc and to write
information into the malloc is solid. Why then ismy program returning an
additional 4 characters?


Write a *minimal* program reproducing your problem, post it here and
you may get some sensible answers.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #22

P: n/a
In <87************@blp.benpfaff.org> Ben Pfaff <bl*@cs.stanford.edu> writes:
"John Tsiombikas (Nuclear / the Lab)" <nu*****@siggraph.org> writes:
Ben Pfaff wrote:
>when I include a header? which header?

You have to include stdlib.h when you use malloc (or provide the
prototype of malloc() yourself, but i can't imagine why you would
prefer to do that)
Providing a prototype of malloc() yourself is arguably not valid
practice based on this sentence from the standard, section 7.1.4:
2 Provided that a library function can be declared without
reference to any type defined in a header, it is also
permissible to declare the function and use it without
including its associated header.
You can certainly declare malloc() without a type defined in a
header, but giving a prototype requires using size_t. It's
better just to use the header.


So are you saying that you can't do the following?

#include <stddef.h> /* for size_t */
void *malloc(size_t);

this is providing a prototype for malloc, without including stdlib.h


You got size_t from a header, which seems to fall afoul of the
spirit of the provision above. Whether it is actually undefined
behavior would be better judged in comp.std.c.


Why is undefined behaviour an option here?

<stddef.h> is the right header to include when you need a definition of
size_t without much additional baggage and his declaration of malloc is
identical to the one provided by the standard itself.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #23

P: n/a
Mark Henning wrote:
"Chris Torek" <no****@torek.net> wrote in message
(although most systems, today,
have an even wider range, about +/- 2 billion).


Only, however, if you live in the US. (Or France).


Works everywhere, on machines with an 11 bit byte and
sizeof(size_t) == 4. :-) That even allows for 2 padding bits.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 14 '05 #24

P: n/a
CBFalconer <cb********@yahoo.com> wrote:
Mark Henning wrote:
"Chris Torek" <no****@torek.net> wrote in message
(although most systems, today,
have an even wider range, about +/- 2 billion).


Only, however, if you live in the US. (Or France).


Works everywhere, on machines with an 11 bit byte and
sizeof(size_t) == 4. :-) That even allows for 2 padding bits.


But in civilised countries, which are not actively trying to make their
national deficit look larger, that won't fit two billion.

Richard
Nov 14 '05 #25

P: n/a
In <c4**********@taliesin2.netcom.net.uk> "Mark Henning" <ma*******@btopenworld.com> writes:
"Chris Torek" <no****@torek.net> wrote in message
(although most systems, today,
have an even wider range, about +/- 2 billion).


Only, however, if you live in the US. (Or France).


In French, this usage of billion is considered an archaism. The current
meaning is 1e12, like in the rest of Europe.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #26

P: n/a
Dan Pop <Da*****@cern.ch> scribbled the following:
In <c4**********@taliesin2.netcom.net.uk> "Mark Henning" <ma*******@btopenworld.com> writes:
"Chris Torek" <no****@torek.net> wrote in message
(although most systems, today,
have an even wider range, about +/- 2 billion).
Only, however, if you live in the US. (Or France).

In French, this usage of billion is considered an archaism. The current
meaning is 1e12, like in the rest of Europe.


Unfortunately, in international discussion, the trend seems to be favour
American forms if at least one American is present. A safe rule of thumb
is "except for political issues, international means American".

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"B-but Angus! You're a dragon!"
- Mickey Mouse
Nov 14 '05 #27

P: n/a
Richard Bos wrote:
CBFalconer <cb********@yahoo.com> wrote:
Mark Henning wrote:
"Chris Torek" <no****@torek.net> wrote in message

(although most systems, today,
have an even wider range, about +/- 2 billion).

Only, however, if you live in the US. (Or France).


Works everywhere, on machines with an 11 bit byte and
sizeof(size_t) == 4. :-) That even allows for 2 padding bits.


But in civilised countries, which are not actively trying to make
their national deficit look larger, that won't fit two billion.


Last time I counted that high 42 bits could describe +- 2e12,
which seems capable of describing most varieties of billion known
to me.

--
Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses. - James Rhodes.

Nov 14 '05 #28

P: n/a
Dan Pop wrote :
In <40*********************@news.club-internet.fr> Richard Delorme <ab****@nospam.fr> writes:
There are such contests for French, too. The winners are usually NOT
native French speakers.


That's not true. The most popular contest is "la dictée de Pivot" also
known as "Les Dicos d'or" and the winners are usually French, but there
is a category for non native French speakers.


Obviously, a non-native French speaker cannot win at the category reserved
to native French speakers :-) I was talking about open contests.


May I know which contests? I know that an Austrian, the Prince of
Metternich supposedly won the famous and first such contest, "la dictée
de Mérimée", but other sources say it was his daugther-in-law, Pauline
Sandoz, a native French speaker and not the Prince himself. Moreover, at
this time (1857), French was the international language used in
diplomacy, so many non native French spearkers possessed an almost
perfect knowledge of the French language, which is not the case anymore.
[...] getting it right when writing requires
a solid understanding of the French grammar (otherwise, it's trivially
easy to mix up, e.g. the infinitive and past participle of most regular
verbs).


Although your last example is a common mistake, it's very easy to avoid
it for a native french speaker: just replace the verb by another one
(usually "prendre") and its pronunciation discriminates between the
infinitive and the past participle.


It doesn't matter how easy it is to avoid, what really matters is that it
is a *very* common mistake. If the written form sounds correctly, far too
many people don't bother to make the slightest effort to check that it is
the correct form.


What I meant is that you don't need a "solid understanding of the French
grammar" to avoid this mistake if you are a native French speaker, as
you can use a simple method based on pronunciation. However it is true
you cannot write correct French without paying some attention.
Besides French grammar, spelling French is difficult because of the many
ways (not as much as English, though) to write the same sound and
because of the presence of mute letters (much more than English), e.g.
"saint", "sain", "sein", "seing", "ceint", "cinq" all share an identical
pronunciation but a different meaning.


It's not that difficult, once you get the hang of it. As a non-native
French speaker I was able to correctly spell words I was hearing for the
first time. And the context helps a lot when disambiguating between
words with identical or near identical pronunciation, just like
in English.


Such words are often used during French spelling contests. For example,
"les cuisseaux de veau et les cuissots de chevreuil" was used by Mérimée
in his famous spelling contest. "Cuissot" and "cuisseau" designate, with
an identical pronunciation, the same part of different animals. As they
are not a very common words, it's quite hard to get the right spelling.

--
Richard
Nov 14 '05 #29

P: n/a
Arthur J. O'Dwyer <aj*@nospam.andrew.cmu.edu> scribbled the following:
On Tue, 13 Apr 2004, Joona I Palaste wrote:
Alberto Giménez <al****@teleline.es> scribbled the following:
> El 8 Apr 2004 08:33:51 GMT, Joona I Palaste escribió:
>> People here might know next to nothing about Finnish, but like it's
>> been said, Finnish is pronounced pretty much like it's written. I have
>> studied (at least cursorily) many languages, and I truly believe Finnish
>> gets the closest to a 1-1 correspondence between written glyphs and
>> spoken sounds.
>
> I'm spanish, and I have to say that spanish is *exactly* pronounced as
> it is written, except for "h" letter, that is not pronounced at all.
Close, but no cigar. Some minor points: Why is the 'u' in "qu"
pronounced differently than the normal 'u'? (For example "una
quilogramme".) Is this correct in some Spanish dialect with which I'm unfamiliar?
I thought the word for "kilogram" in Spanish was... well.. "kilogramo."
Certainly the "gramme" ending in Joona's word isn't Spanish; Spanish
doesn't double consonants. Looks like a weird Ibero-British hybrid
to me. :)
(After Googling: is this something like Catalan?)
I don't know how to spell Spanish correctly. I just have a general idea
of it.
Why do 'l' by itself and "ll" have separate
pronunciations? (I don't know how the "ll" is pronounced correctly,
but I think I know it's *not* pronounced as two 'l' sounds.) The two-'l' letter is the "elle" (pronounced roughly like the
English letter "A": "A-yay"). In words, it's pronounced like the
English 'y': "me llamo" -> "may yamo". And perfectly regularly so. Spanish used to consider both the 'll' and the 'ch' to be letters
in their own right, along with the enye (n+tilde; sorry, not in my
encoding). But IIRC recently the Spanish people in charge of the
"official" language decided to give up the separate letters for 'ch'
and 'll', and now you'll find "llama" in between "liviano" and "local"
in the dictionary.
IMHO, that's just silly. Considering a group of multiple glyphs as a
single letter can be very confusing.
Why can 'y' be both a consonant (like in "yo") and a vowel (like in
"hay")? I'd say, because Spanish doesn't consider 'y' either a consonant or
a vowel, just as in English. The 'y' sound is kind of in-between.
In any event, the 'y' in "yo" isn't really acting like a consonant:
it's just adding the extra "ee" sort of sound. Just like it's doing
in "hay," which without the 'y' would be pronounced "ahh." With the
'y', it's pronounced "ahh-ee," but run together into "ai." [It's weird trying to write down phonetic descriptions in "English"
syllables, when we're talking about a *more* phonetic language in the
first place, and I know English isn't your first language in the second
place. ;) ]
I make a distinction between the consonant and vowel forms. In some
languages, it can even affect the syllable count. Compare the two
Finnish names "Marja" and "Maria". The first is two syllables: Mar-ja.
The second is three syllables: Ma-ri-a.
I suppose 'j' in Spanish is always pronounced like 'h' in English. Correct, AFAIK. Fair enough, but seeing as it's pronounced in Finnish like the
consonant 'y' in English and Spanish, it strikes me as a little weird.

Sounds to me like *Finnish* is the weird one. ;-))


I have to be of the exact opposite opinion. Have you ever looked at
how similar the glyphs 'I' and 'J', or 'i' and 'j' are? And that they're
next to each other in the alphabet?
Especially since 'j' is the only consonant with a dot? It seems clear
that 'j' is intended to be the consonant form of 'i', not some silly 'tsch'
thing like your Anglosaxon has. AFAIK it *was* the consonant form of 'i'
in Latin but it got later corrupted.
Finnish is not the only language to use 'j' as the consonant form of
'i'. At least Swedish, Danish, Norwegian and German also use it.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A bee could, in effect, gather its junk. Llamas (no poor quadripeds) tune
and vow excitedly zooming."
- JIPsoft
Nov 14 '05 #30

P: n/a
In <40**********************@news.club-internet.fr> Richard Delorme <ab****@nospam.fr> writes:
Dan Pop wrote :
In <40*********************@news.club-internet.fr> Richard Delorme <ab****@nospam.fr> writes:
There are such contests for French, too. The winners are usually NOT
native French speakers.

That's not true. The most popular contest is "la dictée de Pivot" also
known as "Les Dicos d'or" and the winners are usually French, but there
is a category for non native French speakers.
Obviously, a non-native French speaker cannot win at the category reserved
to native French speakers :-) I was talking about open contests.


May I know which contests? I know that an Austrian, the Prince of


I don't remember. It's 15 years since I saw something on the TV about
such a contest and I only remember that the winner was not French.
[...] getting it right when writing requires
a solid understanding of the French grammar (otherwise, it's trivially
easy to mix up, e.g. the infinitive and past participle of most regular
verbs).

Although your last example is a common mistake, it's very easy to avoid
it for a native french speaker: just replace the verb by another one
(usually "prendre") and its pronunciation discriminates between the
infinitive and the past participle.


It doesn't matter how easy it is to avoid, what really matters is that it
is a *very* common mistake. If the written form sounds correctly, far too
many people don't bother to make the slightest effort to check that it is
the correct form.


What I meant is that you don't need a "solid understanding of the French
grammar" to avoid this mistake if you are a native French speaker, as
you can use a simple method based on pronunciation.


This was only meant as an example of common problem, see the "e.g."
prefixing it. There are many other cases where the correct form cannot
be decided using a simple-minded heuristic, ranging from plain and simple
conjugation, to subjonctif vs indicatif, si conditionnel, la concordance
des temps.
However it is true
you cannot write correct French without paying some attention.


No amount of attention can compensate a solid knowledge of French grammar.
Besides French grammar, spelling French is difficult because of the many
ways (not as much as English, though) to write the same sound and
because of the presence of mute letters (much more than English), e.g.
"saint", "sain", "sein", "seing", "ceint", "cinq" all share an identical
pronunciation but a different meaning.


It's not that difficult, once you get the hang of it. As a non-native
French speaker I was able to correctly spell words I was hearing for the
first time. And the context helps a lot when disambiguating between
words with identical or near identical pronunciation, just like
in English.


Such words are often used during French spelling contests. For example,
"les cuisseaux de veau et les cuissots de chevreuil" was used by Mérimée
in his famous spelling contest. "Cuissot" and "cuisseau" designate, with
an identical pronunciation, the same part of different animals. As they
are not a very common words, it's quite hard to get the right spelling.


That's exactly what I was talking about: using the context for
disambiguation. Of course, it can only help if you know the words and
their meanings.

And the cuissot vs cuisseau issue is the perversity of a French linguist.
As a result, confusion reigns: try Google searches for
cuisseau-de-chevreuil and cuissot-de-veau and enjoy the results ;-)

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #31

P: n/a
Joona I Palaste wrote:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <c4**********@taliesin2.netcom.net.uk> "Mark Henning" <ma*******@btopenworld.com> writes:
"Chris Torek" <no****@torek.net> wrote in message

(although most systems, today,
have an even wider range, about +/- 2 billion).

Only, however, if you live in the US. (Or France).


In French, this usage of billion is considered an archaism. The current
meaning is 1e12, like in the rest of Europe.

Unfortunately, in international discussion, the trend seems to be favour
American forms if at least one American is present. A safe rule of thumb
is "except for political issues, international means American".

It's just that milliard doesn't seem to roll off the tongue that well. I
don't believe I've heard it in conversation.

--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #32

P: n/a
Joona I Palaste wrote...
Arthur J. O'Dwyer <aj*@nospam.andrew.cmu.edu> scribbled the following:
Spanish used to consider both the 'll' and the 'ch' to be letters
in their own right, along with the enye (n+tilde; sorry, not in my
encoding). But IIRC recently the Spanish people in charge of the
"official" language decided to give up the separate letters for 'ch'
and 'll', and now you'll find "llama" in between "liviano" and "local"
in the dictionary.


IMHO, that's just silly. Considering a group of multiple glyphs as a
single letter can be very confusing.


Nevertheless, it seems to be a very common concept. I now know of three
languages that do this, and i wouldn't be suprised to find out that the
latin letter 'W' originated in this way.

M Henning.
Nov 14 '05 #33

P: n/a
In article <6b********************@comcast.com> Joe Wright <jo********@comcast.net> writes:
....
It's just that milliard doesn't seem to roll off the tongue that well. I
don't believe I've heard it in conversation.


It rolls off perfectly well. I hear it nearly daily when cuts in the
national budget are announced.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #34

P: n/a
In article <c4**********@sunnews.cern.ch> Da*****@cern.ch (Dan Pop) writes:
In <c4**********@taliesin2.netcom.net.uk> "Mark Henning" <ma*******@btopenworld.com> writes:
"Chris Torek" <no****@torek.net> wrote in message
(although most systems, today,
have an even wider range, about +/- 2 billion).


Only, however, if you live in the US. (Or France).


In French, this usage of billion is considered an archaism. The current
meaning is 1e12, like in the rest of Europe.


Since 1948. And before 1700 or something like that. In between it was
1e9 in France. The terms come all in all their meanings from French.
That they botched it is the problem.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #35

P: n/a
Joe Wright wrote:
It's just that milliard doesn't seem to roll off the tongue that well. I
don't believe I've heard it in conversation.


That's only because you hang out with the wrong kind of people. :-)

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #36

P: n/a
CBFalconer <cb********@yahoo.com> wrote:
Richard Bos wrote:
CBFalconer <cb********@yahoo.com> wrote:
Mark Henning wrote:
"Chris Torek" <no****@torek.net> wrote in message

> (although most systems, today,
> have an even wider range, about +/- 2 billion).

Only, however, if you live in the US. (Or France).

Works everywhere, on machines with an 11 bit byte and
sizeof(size_t) == 4. :-) That even allows for 2 padding bits.


But in civilised countries, which are not actively trying to make
their national deficit look larger, that won't fit two billion.


Last time I counted that high 42 bits could describe +- 2e12,
which seems capable of describing most varieties of billion known
to me.


Erm... yes, of course, you're right.

Richard
Nov 14 '05 #37

P: n/a
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:
Unfortunately, in international discussion, the trend seems to be favour
American forms if at least one American is present. A safe rule of thumb
is "except for political issues, international means American".


Alas, these days, that rule of thumb is extremely unsafe _particularly_
for political issues :-(

Richard
Nov 14 '05 #38

P: n/a
In <6b********************@comcast.com> Joe Wright <jo********@comcast.net> writes:
Joona I Palaste wrote:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <c4**********@taliesin2.netcom.net.uk> "Mark Henning" <ma*******@btopenworld.com> writes:

"Chris Torek" <no****@torek.net> wrote in message

>(although most systems, today,
>have an even wider range, about +/- 2 billion).

Only, however, if you live in the US. (Or France).
In French, this usage of billion is considered an archaism. The current
meaning is 1e12, like in the rest of Europe.

Unfortunately, in international discussion, the trend seems to be favour
American forms if at least one American is present. A safe rule of thumb
is "except for political issues, international means American".


It's more an issue of pragmatism: the word milliard doesn't exist in
American English, so they use whatever they have.
It's just that milliard doesn't seem to roll off the tongue that well. I
don't believe I've heard it in conversation.


According to the online M-W, the word only exists in British English.

Apparently, the word started its existence meaning "a very large number".
The Americans decided that 1000 millions is large enough to qualify, while
the Europeans were more conservative.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #39

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El Tue, 13 Apr 2004 21:36:25 GMT, Stephen Sprunk escribió:

"kilogramo" or just "kilo" are the words I know in Spanish, by the way.
However, since 'k' is not in the Spanish alphabet, I presume the correct
spelling is "quilogramo".


k forms part of spanish alphabet (but rarely used). Both words are
accepted.

- --
Alberto Giménez, SimManiac en el IRC
http://www.almorranasozial.es.vg
GNU/Linux Debian Woody 3.0 GnuPG ID: 0x3BAABDE1
Linux registered user #290801
WinError 01E: Timing error - Please wait. And wait. And wait. And wait.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAfYSU0keCtzuqveERAkXIAKCGji7VDPHs14di5HvPiY kMd8JdWQCcD3h8
cpsvJ2lRGGYuU1T4QT+ckkg=
=J2Dy
-----END PGP SIGNATURE-----
Nov 14 '05 #40

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El Tue, 13 Apr 2004 20:30:03 -0400, Joe Wright escribió:
With all due respect, Spain (Iberia) has four (more?) regions with
their own languages. Castille, Andalusia, Catalonia, Basque, etc.
Which of these are you talking about?
Spanish is Spanish, everywhere. Another thing is dialects, or people's
pronounciation. Other topic is Catalan, Basque, "gallego" (don't know
translation), which are languages on their own.

An "andaluz" *should* write spanish exactly as a "castellano" would, but
they pronnounce diferently. It's about "andaluz" dialect, not about
Spanish as a language

Phonetic spelling is tedious so bear with me if you can.
In Spain it is 'tor-TILL-ya' and is very much like an omelette.
In Mexico it is 'tor-TEE-ya' and is a dry corn pancake.


I think this is not what we are discussing here. You are talking about
different meanings of a word. It's not about pronounciation or grammar
rules. Well, south american spanish is quite like a "dialect" of
Spain's, by their pronounciation, but written is the same. A mexican
would write "tortilla" where I write "tortilla" :)

Reading this thread, and your posts, I've seen that spanish has a lot of
grammar and so peculiarities which i don't care, perhaps because i'm
used with the language...

Can I change my opinion and say that spanish is not quite 1-1? :) (of
course, it is more 1-1 than english or french (I also speak catalan,
that is similar to the last one, and has a lot more of peculiarities
than spanish)).

- --
Alberto Giménez, SimManiac en el IRC
http://www.almorranasozial.es.vg
GNU/Linux Debian Woody 3.0 GnuPG ID: 0x3BAABDE1
Linux registered user #290801
WinError 01E: Timing error - Please wait. And wait. And wait. And wait.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAfYg90keCtzuqveERAvJmAJ0arXuPm2+xxqMhOmduWA 8rRrAGKwCfYRLw
I4+mZ6IfH3m0WAUYc/XW5sY=
=ajFX
-----END PGP SIGNATURE-----
Nov 14 '05 #41

P: n/a
Dan Pop <Da*****@cern.ch> scribbled the following:
In <6b********************@comcast.com> Joe Wright <jo********@comcast.net> writes:
Joona I Palaste wrote:
Unfortunately, in international discussion, the trend seems to be favour
American forms if at least one American is present. A safe rule of thumb
is "except for political issues, international means American".
It's more an issue of pragmatism: the word milliard doesn't exist in
American English, so they use whatever they have. It's just that milliard doesn't seem to roll off the tongue that well. I
don't believe I've heard it in conversation.

According to the online M-W, the word only exists in British English. Apparently, the word started its existence meaning "a very large number".
The Americans decided that 1000 millions is large enough to qualify, while
the Europeans were more conservative.


But how does this explain the fact that Europeans use "billion" in the
wrong way too?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Immanuel Kant but Genghis Khan."
- The Official Graffitist's Handbook
Nov 14 '05 #42

P: n/a
Alberto Giménez <al****@teleline.es> scribbled the following:
Can I change my opinion and say that spanish is not quite 1-1? :) (of
course, it is more 1-1 than english or french (I also speak catalan,
that is similar to the last one, and has a lot more of peculiarities
than spanish)).


In fact, having studied quite a few of the Indo-European languages, I
have come to the conclusion that English and French are pretty much
the *only* languages who are not even close to 1-1. The others are
*almost* (but not quite) 1-1.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"C++ looks like line noise."
- Fred L. Baube III
Nov 14 '05 #43

P: n/a
Martin Dickopp wrote:
.... snip ...
Also note that German originally had two glyphs for the letter s: one
for word endings, which looks like the modern letter s, and one for the
middle of words, which looks like the letter f without the horizontal
line. If you imagine a ligature of the latter letter and the letter z,
the similarity to the letter ß is easy to see.


That was also present in English. Supplies all your preffing
needs.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #44

P: n/a
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Alberto Giménez <al****@teleline.es> scribbled the following:
Can I change my opinion and say that spanish is not quite 1-1? :) (of
course, it is more 1-1 than english or french (I also speak catalan,
that is similar to the last one, and has a lot more of peculiarities
than spanish)).


In fact, having studied quite a few of the Indo-European languages, I
have come to the conclusion that English and French are pretty much
the *only* languages who are not even close to 1-1. The others are
*almost* (but not quite) 1-1.


French, unlike English, is very nearly 1-many (or should I say
many-1). Given the spelling of a French word, you can almost always
determine how it's pronounced; going the other way is much more
difficult.

English, on the other hand, is many-many. The spelling of a word is
often insufficient to determine how it's pronounced, and the
pronunciation is often insufficient to determine how it's spelled.
See Dr. Seuss's "The tough coughs as he ploughs the dough" (pronounced
"The tuff coffs as he plows the doe").

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #45

P: n/a

In article <c5**********@oravannahka.helsinki.fi>, Joona I Palaste <pa*****@cc.helsinki.fi> writes:

Yes, and this means that neither Spanish nor English is "pronounced
as written". Finnish is *almost* - the 'n' in "ng" or "nk" is not
pronounced like a normal 'n'. Otherwise it's "pronounced as written".


Japanese is pronounced as written, if you write it that way.

(OK, n' can be pronounced as /n/ or /m/, but that's a trivial
difference and a mistake would never cause confusion.)

If you write Japanese normally, of course, pronunciation can be a
real mystery, particularly for proper nouns.

Japanese can be written phonetically, using the kana syllabaries, but
no one other than young children and people beginning to study
Japanese as a foreign language does that, because it's almost
useless; Japanese is so full of homonyms that it becomes very
ambiguous. So proper written Japanese uses a mix of kana and kanji,
which are logographs adapted from Chinese. Typically kanji represent
the roots of nouns, verbs, adjectives, and adverbs, and kana is used
for grammatical suffixes and particles, other particles that serve as
postpositions, for sounding out onomatopoeia and foreign-origin
loan-words, and so forth.

Since each kanji typically has more than one pronunciation (often
due to associating it with both a spoken Japanese word and the
spoken (in whatever dialect) Chinese word it was adopted from),
reading written Japanese aloud often requires recognizing what word
is meant and then recalling how it's pronounced. And if it's a
proper name, there are often two or more reasonable choices; you
have to find someone who's familiar with the thing being named to
be sure.

Whether that's better or worse than English is a matter of taste.
You have to learn more symbols (about 2000) with Japanese, but
fewer wierd rules and exceptions. And with Japanese it's often
easier to understand the sense of a sentence even when you're not
sure how it should be pronounced.

--
Michael Wojcik mi************@microfocus.com

Thanks for your prompt reply and thanks for your invitatin to your
paradise. Based on Buddihism transmigration, I realize you, European,
might be a philanthropist in previous life! -- supplied by Stacy Vickers
Nov 14 '05 #46

P: n/a
On 6 Apr 2004 15:49:04 GMT, in comp.lang.c , Joona I Palaste
<pa*****@cc.helsinki.fi> wrote:

But how does this explain the fact that Europeans use "billion" in the
wrong way too?


Because we caught the disease from the yanks during WW2 and just after, and
the condition became terminal when the NYSE became the worlds largest money
laundering agency. But don't take my word for it, I only work in capital
markets banking.....

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #47

P: n/a
Joona I Palaste wrote:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <6b********************@comcast.com> Joe Wright <jo********@comcast.net> writes:
Joona I Palaste wrote:

Unfortunately, in international discussion, the trend seems to be favour
American forms if at least one American is present. A safe rule of thumb
is "except for political issues, international means American".
It's more an issue of pragmatism: the word milliard doesn't exist in
American English, so they use whatever they have.


It's just that milliard doesn't seem to roll off the tongue that well. I
don't believe I've heard it in conversation.


According to the online M-W, the word only exists in British English.


Apparently, the word started its existence meaning "a very large number".
The Americans decided that 1000 millions is large enough to qualify, while
the Europeans were more conservative.

But how does this explain the fact that Europeans use "billion" in the
wrong way too?

But this could be important. That Bill Gates is worth $ 0.047 billion
just doesn't have the same 'punch' to it. :-)

--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #48

P: n/a
Irrwahn Grausewitz <ir*******@freenet.de> wrote in
news:o4********************************@4ax.com:
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:
Arthur J. O'Dwyer <aj*@nospam.andrew.cmu.edu> scribbled the following:


<snip>
Spanish used to consider both the 'll' and the 'ch' to be letters
in their own right, along with the enye (n+tilde; sorry, not in my
encoding). But IIRC recently the Spanish people in charge of the
"official" language decided to give up the separate letters for 'ch'
and 'll', and now you'll find "llama" in between "liviano" and
"local" in the dictionary.


IMHO, that's just silly. Considering a group of multiple glyphs as a
single letter can be very confusing.


But it's a concept not unheard of; other examples of ligatures are
the dutch 'ij' ("kijk"), the danish 'ae' (example?), the french 'oe'
("oevre") or the german 'sz' ("Floß").


English had (and still does, occasionally, have) ligatures and 'single
character' replacements too. Most of the silliness of "Ye Olde Print
Shoppe" being pronounced as "Yeee old print shop" was caused by the Herr
Guttenberg's device not having a 'thorn' character. The 'Y' was closest
glyph to it available (as standard), and hence it was common in print.
The thorn character was eventually replaced with 'th'. Remember folks:
"Ye" is just "The"!

(The thorn glyph was used by JRR Tolkien in the runes on the map Thorin
had in the hobbit. It sort of looks like:

|\
|/
|

)

Ian Woods

--
"I'm a paranoid schizophrenic sado-masochist.
My other half's out to get me and I can't wait."
Richard Heathfield
Nov 14 '05 #49

P: n/a
In <t7**********@127.0.0.1> Alberto =?iso-8859-1?Q?Gim=E9nez?= <al****@teleline.es> writes:
El Tue, 13 Apr 2004 20:30:03 -0400, Joe Wright escribió:
With all due respect, Spain (Iberia) has four (more?) regions with
their own languages. Castille, Andalusia, Catalonia, Basque, etc.
Which of these are you talking about?


Spanish is Spanish, everywhere. Another thing is dialects, or people's
pronounciation. Other topic is Catalan, Basque, "gallego" (don't know
translation), which are languages on their own.


Then, why do I see "Castellano" on so many DVDs, instead of "Español"?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #50

144 Replies

This discussion thread is closed

Replies have been disabled for this discussion.