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
144 5428
Old Wolf <ol*****@inspir e.net.nz> scribbled the following: Joona I Palaste <pa*****@cc.hel sinki.fi> wrote: Alberto Giménez <al****@telelin e.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 "yhdysvaltalain en"'s (USAn) pronunication is written in
ASCII-IPA. Turns out it's /yhdysvaltalaine n/.
> 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.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Holy Banana of this, Sacred Coconut of that, Magic Axolotl of the other."
- Guardian in "Jinxter"
In <40************ ***********@new s.syd.swiftdsl. com.au> "Kevin Torr" <ke*******@hotm ail.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
In <87************ @blp.benpfaff.o rg> Ben Pfaff <bl*@cs.stanfor d.edu> writes: "John Tsiombikas (Nuclear / the Lab)" <nu*****@siggra ph.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
Mark Henning wrote: "Chris Torek" <no****@torek.n et> 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?
CBFalconer <cb********@yah oo.com> wrote: Mark Henning wrote: "Chris Torek" <no****@torek.n et> 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
In <c4**********@t aliesin2.netcom .net.uk> "Mark Henning" <ma*******@btop enworld.com> writes: "Chris Torek" <no****@torek.n et> 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
Dan Pop <Da*****@cern.c h> scribbled the following: In <c4**********@t aliesin2.netcom .net.uk> "Mark Henning" <ma*******@btop enworld.com> writes:"Chris Torek" <no****@torek.n et> 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.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"B-but Angus! You're a dragon!"
- Mickey Mouse
Richard Bos wrote: CBFalconer <cb********@yah oo.com> wrote: Mark Henning wrote: "Chris Torek" <no****@torek.n et> 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.
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 pronunciati on 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
Arthur J. O'Dwyer <aj*@nospam.and rew.cmu.edu> scribbled the following: On Tue, 13 Apr 2004, Joona I Palaste wrote: Alberto Giménez <al****@telelin e.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.hel sinki.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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: john smith |
last post by:
Can someone please explain to me what is happening when I do a malloc(0).
This is what I did.
int* p = (int*)malloc(0);
Then I printed the value of p and of course it was non-null.
But has it allocated memory or what?
|
by: Richard Hunt |
last post by:
I'm sorry for asking such a silly question, but I can't quite get my head
around malloc. Using gcc I have always programmed in a lax C/C++ hybrid
(which I suppose is actually c++). But I have started messing around in Plan
9, and that sort of thing is totally no go there :).
Is this correct to allocate memory for my struct? It works on my computer,
but I'm suspicious that I'm doing it wrong.
--
|
by: Brian Blais |
last post by:
Hello,
I saw on a couple of recent posts people saying that casting the return
value of malloc is bad, like:
d=(double *) malloc(50*sizeof(double));
why is this bad? I had always thought (perhaps mistakenly) that the
purpose of a void pointer was to cast into a legitimate date type. Is
this wrong? Why, and what is considered to be correct form?
|
by: Rano |
last post by:
/*
Hello,
I've got some troubles with a stupid program...
In fact, I just start with the C language and sometime
I don't understand how I really have to use malloc.
I've readden the FAQ http://www.eskimo.com/~scs/C-faq/faq.html
but it doesn't seem to answer my questions...
So, I've made an example behind, with some included questions...
|
by: spasmous |
last post by:
main()
{
float * f;
initialize_f(f);
// ...use f for processing
free(f);
}
| |
by: Martin Jørgensen |
last post by:
Hi,
I have a (bigger) program with about 15-30 malloc's in it (too big to
post it here)... The last thing I tried today was to add yet another
malloc **two_dimensional_data. But I found out that malloc always
returned null at this moment and the program exited (even though if I
malloc'ed only 20 bytes or something)... Then I googled for this problem
and found something about a memory pool??? Is that standard C?
I didn't understand it,...
|
by: James Dow Allen |
last post by:
The gcc compiler treats malloc() specially! I have no
particular question, but it might be fun to hear from
anyone who knows about gcc's special behavior.
Some may find this post interesting; some may find it
off-topic or confusing. Disclaimers at end.
The code samples are intended to be nearly minimal
demonstrations. They are *not* related to any
actual application code.
|
by: Why Tea |
last post by:
What happens to the pointer below?
SomeStruct *p;
p = malloc(100*sizeof(SomeStruct)); /* without a cast */
return((void *)(p+1)); /* will the returned pointer point
to the 2nd struct? */
Seems to me there is no guarantee it will.
/Why Tea
|
by: desktop |
last post by:
I have read in Bjarne Stroustrup that using malloc and free should be
avoided in C++ because they deal with uninitialized memory and one
should instead use new and delete.
But why is that a problem? I cannot see why using malloc instead of new
does not give the same result.
|
by: raphfrk |
last post by:
I am having an issue with malloc and gcc. Is there something wrong
with my code or is this a compiler bug ?
I am running this program:
#include <stdio.h>
#include <stdlib.h>
typedef struct pxl {
double lon, lat;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |