473,804 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is it dangerous?

'evening.

I'm not new to C and have been programming in it since I was 8 but
here's a strange problem I've never seen before.

When I compile a program from our C course with a windows compiler
there is no problem but when I try to compile it with a linux compiler
it complains that

a_03.c:(.text+0 x4d): warning: the `gets' function is dangerous
and should not be used.

Is linux more dangerous than windows? Where can I download a
non dangerous gets function? I have never used gets before is
there undefined behavior somewhere?
Here is a trimmed down example program from my assignment that
demonstrates the problem

#include <stdio.h>
#include <malloc.h>

void main()
{
char *string;
printf("enter string (max 2000 chars): ");
fflush(stdin);
fflush(stdout);
string = (char *)malloc(2001);
if(!string) exit(1);
gets(string);
printf("you entered: %s\n", string);
free(string);
exit(0);
}

On windows with TurboC and Lcc no error is printed. On linux with
gcc it says gets is dangerous.

Please advise my instructor says gcc is overly pedantic.
Aug 10 '08
233 8725
Keith Thompson wrote:

It's not an easy problem to solve. Perhaps you might consider giving
Richard a break for trying to use what I consider to be quite an
elegant solution.
Hmmmm, no.

Brian
Aug 14 '08 #111
Default User said:
Richard Heathfield wrote:
>Default User said:
I don't believe to be well-established at all.

Since you're being so picky about language, perhaps you should
examine the grammar of that sentence more closely.

Are you claiming that Usanians was a typo?
No, I'm pointing out that your complaining about it constitutes a complaint
about language usage. Those who complain about others' language usage are
in a weak position if their own language usage is not perfect.
Are you seriously going to nitpick about a typo? That's pretty weak.

Are you seriously going to nitpick about an accurate descriptive
term? That's even weaker.

It's not accurate, it's not even sensible. USA is a recognized
abbreviation.
Yes.
"Usa" is not a word.
Right. But "Usanian" /is/ a word.
To further hang a suffix off it is
ridiculous.
Nobody is forcing you to use it.
It looks silly, and you offend Americans.
Only the vanishingly small percentage of Americans who are both (a)
citizens of the USA and (b) ludicrously thin-skinned.
Whether you want
to admit it or not, the typical term for people from the only nation
with American in its name is "American".
Oh, I admit freely that the word "American" is misused by the vast majority
of people. So what? Most people void main too. That doesn't make it right.
In both the USA and the
UK. That includes every dictionary of the English language. But you
knew that.

Dictionaries are descriptive, not prescriptive, and in any case lag
behind neologisms by a number of years.

That's true, but they're the best we have.
No, clarity of thought is the best we have.
It also doesn't make all neologisms sensible.
It is true that not all neologisms are sensible.
Further it doesn't address the offensive nature of some.
Now this, I just don't get. How on *earth* is the word "Usanian" offensive?
>If you don't like my use of
language, well, neither are you under any obligation to read my
articles or provide me with help.

I'm also free to complain about your offensive usage.
What offensive usage? What's offensive about the word? I don't understand
that at all.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 14 '08 #112
Richard Heathfield wrote:
[OT]
Default User said:
Richard Heathfield wrote:
Default User said:
....
Well, Usanians. Do you think that is a standard abreviation?

It's not an abbreviation. It's a neologism (but it's a strange breed
of neologism, since it's now quite well-established).
....
It's also insulting to many Americans. But you knew that already.

No, it isn't,
Yes, it is. I understand and sympathize with the reasons why you don't
want to use the term American to describe my fellow citizens. However,
I can assure you that the overwhelming majoring of them are not even
aware of the issue, and most of them would not sympathize even if they
were aware. They would consider it insulting that you called us by any
name other than the "correct" one. They would be just as insulted as a
British citizen might be at being called an Englishman, if he wasn't
actually English (most Americans don't even know that such a thing is
even possible, much less understand why it might be considered
insulting). Also, for that particular alternative, many of us, myself
included, would wonder whether a pun somehow connected with the word
"insane" was intended.
[/OT]
Aug 14 '08 #113
Richard Heathfield wrote:

What offensive usage? What's offensive about the word? I don't
understand that at all.
Well Ricky, if you don't understand after what I've told you, I suppose
I won't able to explain it. I guess you could take it on faith.

Brian
Aug 14 '08 #114
"Default User" <de***********@ yahoo.comwrites :
Keith Thompson wrote:
>It's not an easy problem to solve. Perhaps you might consider giving
Richard a break for trying to use what I consider to be quite an
elegant solution.

Hmmmm, no.
You say you're offended by the term "Usanian". That is of course your
right. But I am now offended by your repeated whining about it,
especially since you appear to be claiming the right to be offended on
my behalf.

At the very least, please consider the possibility that people who use
the term are not being *deliberately* offensive.

Better yet, consider that you appear to be the *only* person who holds
this particular opinion, that you have not changed anyone's mind, that
you are not likely to do so in the future, and that *this has nothing
to do with C*. I request that you find another forum for your
complaints on this matter, perhaps private e-mail.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 14 '08 #115
ja*********@ver izon.net said:
Richard Heathfield wrote:
[OT]
>Default User said:
Richard Heathfield wrote:

Default User said:
...
Well, Usanians. Do you think that is a standard abreviation?

It's not an abbreviation. It's a neologism (but it's a strange breed
of neologism, since it's now quite well-established).
...
It's also insulting to many Americans. But you knew that already.

No, it isn't,

Yes, it is.
Okay, I'll concede that some United States citizens may be dense enough to
be offended by the term.
I understand and sympathize with the reasons why you don't
want to use the term American to describe my fellow citizens.
Thank you.
However,
I can assure you that the overwhelming majoring of them are not even
aware of the issue,
I can believe it. (Sturgeon's Law applies, even to people - and not just
your fellow citizens, I hasten to add.)
and most of them would not sympathize even if they
were aware. They would consider it insulting that you called us by any
name other than the "correct" one.
I accept that "American" is a correct description of citizens of the USA -
just as it is a correct description of Canadians, Colombians, Cubans, and
Chileans. Nevertheless, a more localised adjective is useful (just as it
is for Canadians, Colombians, Cubans, and Chileans). If "Usanian" is
offensive for some bizarre reason, fine, someone coin another word. (I did
so, many years ago - "Usanese" - but someone pointed out the prior
existence of "Usanian", and I was quite content to drop my term in favour
of one already extant.)
They would be just as insulted as a
British citizen might be at being called an Englishman,
I can't see how that would be an insult.
if he wasn't actually English
Ah, that would do it. :-) But I don't see the parallel. I use the term
"Usanian" only to apply to those who are citizens of the USA. Those who
are not citizens of the USA have no grounds for being offended by the
term, since I'm not applying it to them. (And those who are, have no
grounds either, since there's nothing remotely offensive about it.)
(most Americans don't even know that such a thing is
even possible, much less understand why it might be considered
insulting).
Sturgeon's Law again, you see.
Also, for that particular alternative, many of us, myself
included, would wonder whether a pun somehow connected with the word
"insane" was intended.
Not when I use it, it isn't. Purely descriptive - no side, no spin, no pun.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 14 '08 #116
Default User said:
Richard Heathfield wrote:

>What offensive usage? What's offensive about the word? I don't
understand that at all.

Well Ricky,
Yes, Mr User? That's a silly game to play with a name like yours, but okay,
whatever.
if you don't understand after what I've told you, I suppose
I won't able to explain it. I guess you could take it on faith.
Well, no. You see, I know that lots of people think "faith" means
"believing in stuff even though you know it's not true", but I actually
think it means the opposite - believing in stuff because you know it *is*
true, even when it might seem not to be. When I'm in the dentist's chair,
it is faith in the dentist that keeps me from bolting for the door - I
have faith that she's doing me good, even though she's causing me a
certain amount of pain and a great deal of discomfort. When I'm looking at
a diagnostic message, it is faith in the compiler that leads me to suspect
my own code to be faulty even though I can see absolutely nothing wrong
with it.

Whilst my experience of your contributions to this newsgroup lead me to
respect your knowledge of C, I have no particular reason to have faith in
your ability to be objective about language usage. So the most likely
explanation I have for your apparent lack of objectivity now is that it is
an actual lack of objectivity. No need to take anything on faith.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 14 '08 #117
Keith Thompson wrote:
"Default User" <de***********@ yahoo.comwrites :
Keith Thompson wrote:
It's not an easy problem to solve. Perhaps you might consider
giving >Richard a break for trying to use what I consider to be
quite an >elegant solution.

Hmmmm, no.

You say you're offended by the term "Usanian". That is of course your
right. But I am now offended by your repeated whining about it,
Ok. And I'm offended by you being offended by my being offended. And so
on.
At the very least, please consider the possibility that people who use
the term are not being deliberately offensive.
I don't actually believe that. I believe it to be dig (minor and more
with sniggering humor than real malice) at Americans to use that term.
I don't for a minute believe that users of the term are bleeding their
hearts for the Costa Ricans and such shut out by the use of the term to
mean only those from the USA.
Certainly Mr. Heathfield is aware of my feelings on the matter.
Better yet, consider that you appear to be the only person who holds
this particular opinion
One of two, it would now seem, on this newsgroup.
that you have not changed anyone's mind, that
you are not likely to do so in the future, and that *this has nothing
to do with C*. I request that you find another forum for your
complaints on this matter, perhaps private e-mail.
Hmmmm, no. I'm done with it for this time, I think. Next time will be a
new time.


Brian

Aug 14 '08 #118
Default User said:
Keith Thompson wrote:
<snip>
>At the very least, please consider the possibility that people who use
the term are not being deliberately offensive.

I don't actually believe that.
So why should I believe *that*? If you aren't prepared to trust reasonable
people to tell the truth, you should not be surprised if they withdraw
their trust from you. I have stated publicly that I do not use the term to
offend, merely to describe. If you don't believe me, well, that's up to
you, but if you think the term "Usanian" is offensive, how do you feel
about the term "liar"?

<snip>
>Better yet, consider that you appear to be the only person who holds
this particular opinion

One of two, it would now seem, on this newsgroup.
Who is the other one? If you mean James Kuyper, it seems to me that his
position on the term is considerably more moderate than yours, and that
therefore he does not share your opinion.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 14 '08 #119
On 14 Aug 2008 at 22:30, Default User wrote:
Keith Thompson wrote:
>You say you're offended by the term "Usanian".
[snip]
>*this has nothing to do with C*.

Hmmmm, no.
Hmmmm, yes.

I don't mind people discussing HeathField's eccentricities in this group
if they like - it's just the sheer damned hypocrisy that I can't stand.
The Loser and Kuyper and Heathfield are the first to scream "off topic"
at others, but somehow it's a different rule for them when they want to
go on for post after post about some petty idiosyncrasy of RJH.

At least Thomson is consistent in his narrow-minded approach to
"topicality ".

Aug 14 '08 #120

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

Similar topics

101
3397
by: Bill Cunningham | last post by:
I read an article in a book about Perl and Common Gateway Interface and it mentioned C. It said that C could damage your computer. I don't know wether it meant the standard or compiler issuses. I was a little upset. Well more upset. I sent Dennis Ritchie and email. I don't know if he'll respond if he gets it. Sometimes he does sometimes not. How can C damage your computer? Bill
1
2842
by: b83503104 | last post by:
When are they not consistent?
4
1302
by: cesark | last post by:
Hi ! I have important doubts about how to handle the security in asp.net vb.net web forms. Somebody can help me? 1. If you have setting ‘validateRequest=true’ in .net framework1.1, What can do you do to improve the security? Because although you have validations on server side you can enter dangerous characters in a text field, with the exception of telephone numbers or similar.
302
18625
by: Lee | last post by:
Hi Whenever I use the gets() function, the gnu c compiler gives a warning that it is dangerous to use gets(). Is this due to the possibility of array overflow? Is it correct that the program flow can be altered by giving some specific calculated inputs to gets()? How could anyone do so once the executable binary have been generated? I have heard many of the security problems and other bugs are due to array overflows.
6
7469
by: Brendan | last post by:
Hi, I'm trying to mimic the IPC/messaging system of an specific OS in a portable way by using GCC's library. The IPC system uses buffered asynchronous messages, where any thread can send a message to any other thread (i.e. to the "threadID") without blocking, and the receiver does any security checks necessary. I'm trying to implement the portable/linux version on top of sockets/datagrams ("SOCK_DGRAM" in the local namespace), and so...
10
9370
by: lovecreatesbea... | last post by:
C stops the conversion from (char **) to (const char **). c-faq.com sec 11.10 has explanation on this point. But, for example, even the conversion from (char *) to (const char *) brings the same dangerous as in the previous conversion. Why the latter simple but dangerous one is allowed in C? $ cat f1.c int main(void) { const char c = 'a';
6
3580
by: Thomas.li | last post by:
Hi, I want to convert CString to LPBYTE like LPBYTE lpByte = (BYTE*)(LPCTSTR)cstring; is it very dangerous to do that?
0
10343
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...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7633
isladogs
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...
0
6862
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
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
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
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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.