473,804 Members | 1,999 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 8724
Doug Miller said:
In article <AI************ *************** ***@bt.com>, rj*@see.sig.inv alid
wrote:
>>Understood. Nevertheless, to co-opt a term that describes the population
of a whole continent - nay, *two* whole continents - and apply it only to
an admittedly large minority of that population is self-aggrandising, and
it should not surprise us to learn that those who seek
self-aggrandisement are not going to be best pleased by the introduction
of a term which neutralises it.

You don't honestly believe that citizens of Canada, Mexico, or Brazil
think of themselves as "Americans" , do you?
I don't honestly believe that calling a trunk an elephant makes it an
elephant.

--
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 15 '08 #131
Doug Miller said:
In article <6g************ @mid.individual .net>, "Default User"
<de***********@ yahoo.comwrote:
>>Keith Thompson wrote:
>>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.

Moreover, once one has been informed that the use of a particular word,
phrase, etc. causes offense, to continue to use that word, phrase, etc.
*is* being deliberately offensive.
Fine. For future reference, I find these following terms deeply upsetting,
and would appreciate your refraining from their usage:

"a", "been", "being", "causes", "continue", "deliberate ly", "etc", "has",
"informed", "is", "moreover", "of", "offense", "offensive" , "once", "one",
"particular ", "phrase", "that", "the", "to", "use", "word".

and I found your paragraph very disturbing.

You now have some choices:

(a) refuse to believe that I find those words offensive (as I refuse to
believe that anyone can seriously find the word "Usanian" offensive);
(b) consider that I'm being ridiculous (as I consider that anyone finding
the word "Usanian" offensive is being ridiculous);
(c) refrain from using any of the words I mentioned above in all
comp.lang.c articles, from now on.

Choice (c), the only choice in keeping with your position, is untenable.
The other two choices reflect my position nicely.

--
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 15 '08 #132
Joe Wright <jo********@com cast.netwrites:
[...]
I think you have it completely wrong friend Richard. Over here in the
New World we identify with our nationality, not geography. No one over
here thinks of themselves in continental terms, North or South
American, rather in terms of our nationality. Canadian, Mexican,
Brazilian, Argentinian. And American because our nation is United
States of America.

'American' is not a correct description of Canadians or Chileans.
Do you speak for Canadians, Mexicans, Brazilians, and Argentinians?

You certainly don't speak for all citizens of the US.

--
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 15 '08 #133
Doug Miller wrote:
rj*@see.sig.inv alid wrote:
>Understood. Nevertheless, to co-opt a term that describes the
population of a whole continent - nay, *two* whole continents -
and apply it only to an admittedly large minority of that
population is self-aggrandising, and it should not surprise us
to learn that those who seek self-aggrandisement are not going
to be best pleased by the introduction of a term which
neutralises it.

You don't honestly believe that citizens of Canada, Mexico, or
Brazil think of themselves as "Americans" , do you?
Certainly do. They may even add a North, South, Central to it. Or
nothing.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Aug 15 '08 #134
Doug Miller wrote:
"Default User" <de***********@ yahoo.comwrote:
>Keith Thompson wrote:
>>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.

Moreover, once one has been informed that the use of a
particular word, phrase, etc. causes offense, to continue to use
that word, phrase, etc. *is* being deliberately offensive.
No, you miss the point. It is much better to doggedly defend your
attitude, and to cause the injection of roughly 100 OT messages
into the newsgroup, than to ever concede a point. This works
especially well when two opposing attitudes are present. We can be
thankful that the protagonists are fairly well trained in snipping
and bottom-posting.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.

Aug 15 '08 #135
Keith Thompson wrote:
Joe Wright <jo********@com cast.netwrites:
[...]
>I think you have it completely wrong friend Richard. Over here in the
New World we identify with our nationality, not geography. No one over
here thinks of themselves in continental terms, North or South
American, rather in terms of our nationality. Canadian, Mexican,
Brazilian, Argentinian. And American because our nation is United
States of America.

'American' is not a correct description of Canadians or Chileans.

Do you speak for Canadians, Mexicans, Brazilians, and Argentinians?

You certainly don't speak for all citizens of the US.
What? I speak for myself of course. But if you ask a Canadian if he's an
American he'll say "No, I'm Canadian". Every time.

Do you know Nova Scotians or Brazilians who think of themselves as
American? I suppose not.

All citizens of the USA are American by definition. The adjective
'American' applies to the USA only.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Aug 15 '08 #136
Doug Miller wrote:
In article <AI************ *************** ***@bt.com>, rj*@see.sig.inv alid wrote:
>Understood. Nevertheless, to co-opt a term that describes the population of
a whole continent - nay, *two* whole continents - and apply it only to an
admittedly large minority of that population is self-aggrandising, and it
should not surprise us to learn that those who seek self-aggrandisement
are not going to be best pleased by the introduction of a term which
neutralises it.

You don't honestly believe that citizens of Canada, Mexico, or Brazil think of
themselves as "Americans" , do you?
Actually, in Latin America that is in fact the case:

<http://en.wikipedia.or g/wiki/American_(word) #Political_and_ cultural_views>
Aug 15 '08 #137
On Aug 14, 8:41 pm, Richard Heathfield <rj*@see.sig.in validwrote:
Doug Miller said:
In article <6g************ @mid.individual .net>, "Default User"
<de***********@ yahoo.comwrote:
>Keith Thompson wrote:
>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.
Moreover, once one has been informed that the use of a particular word,
phrase, etc. causes offense, to continue to use that word, phrase, etc.
*is* being deliberately offensive.

Fine. For future reference, I find these following terms deeply upsetting,
and would appreciate your refraining from their usage:

"a", "been", "being", "causes", "continue", "deliberate ly", "etc", "has",
"informed", "is", "moreover", "of", "offense", "offensive" , "once", "one",
"particular ", "phrase", "that", "the", "to", "use", "word".

and I found your paragraph very disturbing.

You now have some choices:

(a) refuse to believe that I find those words offensive (as I refuse to
believe that anyone can seriously find the word "Usanian" offensive);
(b) consider that I'm being ridiculous (as I consider that anyone finding
the word "Usanian" offensive is being ridiculous);
(c) refrain from using any of the words I mentioned above in all
comp.lang.c articles, from now on.

Choice (c), the only choice in keeping with your position, is untenable.
The other two choices reflect my position nicely.
So let me see if I got this right...

Off-topic:

- Networking in C
- Threading in C
- Creating directories in C
- Future C standards
- Programs written in C

On-topic:

- Prototyping main()
- (Not) casting malloc() calls
- Proper use of English words
- Nationalities abbreviations

:-)

Sebastian

Aug 15 '08 #138
s0****@gmail.co m wrote:

<snip>
So let me see if I got this right...

Off-topic:
[ ... ]
- Future C standards
There is <news:comp.std. cfor this.
- Programs written in C
I would say that this is topical. If the problem involves an extension
then we can always redirect the OP.

<snip>

Aug 15 '08 #139
"Default User" <de***********@ yahoo.comwrote:
Richard Heathfield wrote:
Alas, many Usanians tend not to notice it.

Please try not to use odd abbreviations that are not standard English.
Why? Do you USAliens not have the graps of the English language to
understand them?

Richard
Aug 15 '08 #140

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
18624
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
10594
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
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
10331
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
10087
tracyyun
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...
0
9166
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...
0
6861
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
5529
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
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.