'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 8947
Richard Heathfield <rj*@see.sig.in validwrites:
Ben Bacarisse said:
>Richard Heathfield <rj*@see.sig.in validwrites:
>>Default User said: Richard Heathfield wrote: Default User said: > Please try not to use odd abbreviations that are not standard English. > Such as?
Well, Usanians. Do you think that is a standard abreviation?
It's not an abbreviation.
...and later...
| United States of America -United States of American (for which | "Usanian" is a convenient contraction).
No contradiction, according to my lights.
In the part you clipped I said this was another whole pin-full of
angels to count -- i.e. that it is endlessly debatable.
When I was in school, I was
taught that to form an abbreviation you took the first letter of each
word, as in "BBC" for "British Broadcasting Corporation", "RAF" for "Royal
Air Force", "MCC" for "Marylebone Cricket Club", etc. (If they happened to
form a pronounceable word, then you had not only an abbreviation but also
an acronym.) But "contractio n" was a more general term that referred to a
more general shortening, not merely the taking of each first letter.
OK. While I would not trust my schooling to have been accurate about
anything, I accept that you might. I won't cite any authorities in
support of a much broader meaning for the term because that would just
invite you to cite still more. Instead, I invite you to agree that it
is debatable and that we should not debate it here.
--
Ben.
CBFalconer wrote:
Richard Heathfield wrote:
>>
... snip ...
>> No contradiction, according to my lights. When I was in school, I was taught that to form an abbreviation you took the first letter of each word, as in "BBC" for "British Broadcasting Corporation", "RAF" for "Royal Air Force", "MCC" for "Marylebone Cricket Club", etc. (If they happened to form a pronounceable word, then you had not only an abbreviation but also an acronym.) But "contractio n" was a more general term that referred to a more general shortening, not merely the taking of each first letter.
I see none of this in any C99 standard.
A bit too late for this thread. Just killfile it.
Paul Hsieh wrote:
On Aug 14, 10:16*pm, s0s...@gmail.co m wrote:
>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
You forgot:
- The general practice of programming and computer science
comp.programmin g?
[ ... ]
- Any real world program written in C outside of command line
utilities
They are topical. However most of the posters are newbies with
elementary questions.
- Comparisons of C with any other language
This should be topical, though of course, it's prone to spiralling into
flamewars.
<snip>
Antoninus Twink wrote:
On 11 Aug 2008 at 22:17, Richard Heathfield wrote:
>Willem said:
>>The person driviong that other car would, if you were killed, have the very traumatic experience of having caused your death, as opposed to just causing you some injuries had you worn your seatbelt.
They might also suffer the even more traumatic experience of having you smash through their windscreen, injuring or even killing them.
Oh come on, has this ever actually happened?
Yes it surely has. It has also happend that passengers not using their belt
injured/killed the (belted) driver in such accidents.
Bye, Jojo
Joachim Schmitz wrote:
Antoninus Twink wrote:
>On 11 Aug 2008 at 22:17, Richard Heathfield wrote:
>>Willem said: The person driviong that other car would, if you were killed, have the very traumatic experience of having caused your death, as opposed to just causing you some injuries had you worn your seatbelt. They might also suffer the even more traumatic experience of having you smash through their windscreen, injuring or even killing them.
Oh come on, has this ever actually happened?
Yes it surely has. It has also happend that passengers not using their belt
injured/killed the (belted) driver in such accidents.
Which is why sensible countries require back seat passengers to wear
seatbelts. How does this relate to C by the way?
--
Ian Collins.
On 16 Aug 2008 at 10:38, Joachim Schmitz wrote:
Antoninus Twink wrote:
>On 11 Aug 2008 at 22:17, Richard Heathfield wrote:
>>They might also suffer the even more traumatic experience of having you smash through their windscreen, injuring or even killing them.
Oh come on, has this ever actually happened?
Yes it surely has. It has also happend that passengers not using their belt
injured/killed the (belted) driver in such accidents.
[citation needed]
Ian Collins said:
Joachim Schmitz wrote:
>Antoninus Twink wrote:
>>On 11 Aug 2008 at 22:17, Richard Heathfield wrote: Willem said: The person driviong that other car would, if you were killed, have the very traumatic experience of having caused your death, as opposed to just causing you some injuries had you worn your seatbelt. They might also suffer the even more traumatic experience of having you smash through their windscreen, injuring or even killing them. Oh come on, has this ever actually happened?
Yes it surely has. It has also happend that passengers not using their belt injured/killed the (belted) driver in such accidents.
Which is why sensible countries require back seat passengers to wear
seatbelts. How does this relate to C by the way?
It's an analogy to do with the use of gets(), first raised in this thread
by Eric Sosman, in which he suggests that those who use gets() despite its
known dangers are analogous to those who refuse to wear seatbelts. As
such, it's reasonably relevant. Although it is possible to stretch an
analogy too far (which is why "proof by analogy is fraud", as Stroustrup
rightly said), I don't think this has happened yet in the current case.
--
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
In article <jr************ *************** ***@bt.com>, rj*@see.sig.inv alid wrote:
>Doug Miller said:
>In article <Wu************ *************** ***@bt.com>, rj*@see.sig.inv alid wrote:
>>>Doug Miller said:
I'm guessing you don't know many (if any) Canadians ...
A few.
Not very well, evidently.
Begging the question.
I notice you snipped the rest of my post, restored here for your convenience:
---------------
I spent several years working for a small US subsidiary of a much larger
Canadian firm. I can assure you that *none* of the Canadians I worked with
thought of themselves as "Americans" .
>or you wouldn't imagine that they would think of themselves as "Americans" .
>Really.
Ask them.
----------------
Go on -- ask those few Canadians of your acquaintance how they think of
themselves. Ask them if they consider themselves to be Americans. If fortune
smiles on you, all they will do is laugh uproariously, or simply give you a
puzzled look.
Doug Miller said:
In article <jr************ *************** ***@bt.com>, rj*@see.sig.inv alid
wrote:
>>Doug Miller said:
>>In article <Wu************ *************** ***@bt.com>, rj*@see.sig.inv alid wrote: Doug Miller said:
I'm guessing you don't know many (if any) Canadians ...
A few.
Not very well, evidently.
Begging the question.
I notice you snipped the rest of my post,
Yes, because the part of your response to which I was replying was the part
in which you were begging the question. The rest of your post was merely
anecdotal, and I had no comment to make on it, which is why I snipped it.
restored here for your convenience:
No point. I have no comment to make on your experience, which differs from
mine. It is possible that you are confused by the fact that Canadians are
likely to think of and describe themselves as Canadians rather than
Americans for the same reason that Germans are likely to think of and
describe themselves as Germans rather than Europeans. That does not mean
that Canadians are not Americans, any more than it means that Germans are
not Europeans.
<snip>
--
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
In article <WL************ *************** ***@bt.com>, rj*@see.sig.inv alid wrote:
>No point. I have no comment to make on your experience, which differs from mine. It is possible that you are confused by the fact that Canadians are likely to think of and describe themselves as Canadians rather than Americans for the same reason that Germans are likely to think of and describe themselves as Germans rather than Europeans. That does not mean that Canadians are not Americans, any more than it means that Germans are not Europeans.
You seem determined to ignore the point here: Canadians *don't* consider
themselves to be "Americans" , your anti-American fantasies to the contrary
notwithstanding . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
by: b83503104 |
last post by:
When are they not consistent?
|
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.
|
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.
|
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...
| |
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';
|
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?
|
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: 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...
|
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: 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...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |