473,804 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

malloc + 4??

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 5431
"Alan Balmer" <al******@att.n et> wrote in message
news:rv******** *************** *********@4ax.c om...
On Fri, 9 Apr 2004 18:20:50 +0100, "Peter Pichler" <pi*****@pobox. sk>
wrote:
The same can be said about the English. The first time I've read 'their'
instead of 'there' in a paper, it confused me so much that I had to go
to the author to ask him WTF he'd meant.


My current pet peeve is "lose" and "loose".


I've always had a fondness for "read", which can be pronounced like either
"red" or "reed", and may mean a present tense verb, past tense verb, or a
noun. Americans are particularly bad about turning verbs into nouns and
vice versa without changing the spelling, which also confuses a new speaker.

As a native English speaker, I've never had trouble correctly spelling or
pronouncing words I've never seen or heard before, but that's because my
parents used a very different method to teach me than what's used in
schools. Particularly, they taught me words in groups which had similar
behavior instead of groups that had similar meanings; I now know that
behavior follows what language English "borrowed" the word from, and can
apply that to new words without trouble.

Another oddity of English is that while there many synonyms for most common
words, non-native speakers tend to only learn and use one of them, usually
the one that most resembles their own language. This leads to situations
where, for example, a native speaker has to translate between an Asian and a
European both speaking mutually exclusive subsets of English.

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 #101
"CBFalconer " <cb********@yah oo.com> wrote in message
news:40******** *******@yahoo.c om...
Keith Thompson wrote:
And similarly, "the" is pronounced with a long 'e' when followed
by a vowel, though the spelling doesn't change.


Oh? I would pronounce "the ant" just the same as "the cat".


"Thee ant" flows more naturally than "thuh ant", whereas "thee cat" is less
natural than "thuh cat". Some people only say "thee" or "thuh" in all
cases, but it seems more common for pronunciation to mutate based on the
following word.

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 #102
Stephen Sprunk wrote:
"Alan Balmer" <al******@att.n et> wrote in message
"Peter Pichler" <pi*****@pobox. sk> > wrote:

The same can be said about the English. The first time I've
read 'their' instead of 'there' in a paper, it confused me so
much that I had to go to the author to ask him WTF he'd meant.


My current pet peeve is "lose" and "loose".


I've always had a fondness for "read", which can be pronounced
like either "red" or "reed", and may mean a present tense verb,
past tense verb, or a noun. Americans are particularly bad
about turning verbs into nouns and vice versa without changing
the spelling, which also confuses a new speaker.


Every so often I have to look with horror on what came back after
I post something. My minor typos insist on looking like ignorant
spelling foulups. I especially remember a lose/loose foulup a few
days ago. I have even fouled there/their.

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

Nov 14 '05 #103
"CBFalconer " <cb********@yah oo.com> wrote in message
Every so often I have to look with horror on what came back after
I post something. My minor typos insist on looking like ignorant
spelling foulups. I especially remember a lose/loose foulup a few
days ago. I have even fouled there/their.


:-)

Lose/loose can be explained as a simple typo. Bot for us, non-native
speakers, who'd learnt the language mostly by reading, there and
their are *visually* two completely different things. And I usually
don't bother pronouncing it when I'm reading it, that would slow me
down. The visual information is all I need. Thus errors like these
can sometimes confuse me, though not for longer than a second or two
nowadays.

Now, can this explain so many readers confusing C and C++?

Peter
Nov 14 '05 #104
"Stephen Sprunk" <st*****@sprunk .org> writes:
I've always had a fondness for "read", which can be pronounced like either
"red" or "reed", and may mean a present tense verb, past tense verb, or a
noun. Americans are particularly bad about turning verbs into nouns and
vice versa without changing the spelling, which also confuses a new speaker.


I'm fond of "resent", which can be interpreted as "feel bitter or
indignant about" or "sent again". The ambiguity between these
two meanings can occasionally be important. As a result I always
hyphenate the latter into "re-sent".
--
"This is a wonderful answer.
It's off-topic, it's incorrect, and it doesn't answer the question."
--Richard Heathfield
Nov 14 '05 #105
In <40************ *********@news. club-internet.fr> Richard Delorme <ab****@nospam. fr> writes:
Dan Pop a écrit :
In <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> 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
pronunciatio n 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 #106
In <rv************ *************** *****@4ax.com> Alan Balmer <al******@att.n et> writes:
"Dan Pop" <Da*****@cern.c h> wrote in message
news:c5****** *****@sunnews.c ern.ch...
BTW, the average native French speaker can speak French grammatically
correct, but cannot write French grammatically correct.


Shouldn't that be "the average native French speaker can speak
grammaticall y correct French , but cannot write grammatically correct
French"?


Could be. I'm not a native English speaker and I've never bothered to
study the English grammar.

Dan
Nov 14 '05 #107
-----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

iD8DBQFAe9Qa0ke CtzuqveERAgKPAJ wN/1O1uFE2KwfXP8eO D+K++zQNMgCfQk3 O
ZBo2H5wau7YLtS3 ZmC+LUfU=
=olv1
-----END PGP SIGNATURE-----
Nov 14 '05 #108
-----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 "peculiarit y", 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

iD8DBQFAe9UD0ke CtzuqveERAqFiAJ 9d03tx0rF+ewWTZ L2vwMb7y1HPfwCd EXln
yjzYZb/1TY3ctvowwN/FqQI=
=qK14
-----END PGP SIGNATURE-----
Nov 14 '05 #109
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".) 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.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It was, er, quite bookish."
- Horace Boothroyd
Nov 14 '05 #110

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
683
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?
34
6449
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. --
231
23256
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?
7
2219
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...
20
10765
by: spasmous | last post by:
main() { float * f; initialize_f(f); // ...use f for processing free(f); }
15
2593
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,...
68
15722
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.
40
2612
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
71
19145
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.
23
2736
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;
0
9715
marktang
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...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
jinu1996
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...
0
6869
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();...
0
5536
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...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
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
3
3003
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.