I wrote this program which guarantees to use gets safely.
#include <stdio.h>
int main(void)
{
char name[588+1];
printf("Enter your last name: ");
fflush(stdout);
printf("Hi %s\n",gets(name));
return 0;
}
You see, the longest last name in the world is 588 characters, as
explained here: http://www.everything2.com/index.pl?node_id=1534419
So, my program works for everyone in the world. Guaranteed.
--
Billy 18 1657
On Jan 14, 9:27*pm, Billy Bong <billyb655...@aol.comwrote:
I wrote this program which guarantees to use gets safely.
#include <stdio.h>
int main(void)
{
* *char name[588+1];
* *printf("Enter your last name: ");
* *fflush(stdout);
* *printf("Hi %s\n",gets(name));
* *return 0;
}
You see, the longest last name in the world is 588 characters, as
explained here:
http://www.everything2.com/index.pl?node_id=1534419
So, my program works for everyone in the world. Guaranteed.
What if they type in an extra ten letters, just for fun?
What if they feed it a 100 MB binary file?
In article <9c**********************************@v29g2000hsf. googlegroups.com>,
user923005 <dc*****@connx.comwrote:
>On Jan 14, 9:27=A0pm, Billy Bong <billyb655...@aol.comwrote:
>I wrote this program which guarantees to use gets safely.
>=A0 =A0char name[588+1];
>=A0 =A0printf("Hi %s\n",gets(name));
>You see, the longest last name in the world is 588 characters, as explained here:
>http://www.everything2.com/index.pl?node_id=1534419
>So, my program works for everyone in the world. Guaranteed.
>What if they type in an extra ten letters, just for fun?
Or if they have a typo in their own name (not unlikely in 588
characters).
--
"Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us." -- Ecclesiastes
Billy Bong wrote:
I wrote this program which guarantees to use gets safely.
#include <stdio.h>
int main(void)
{
char name[588+1];
printf("Enter your last name: ");
fflush(stdout);
printf("Hi %s\n",gets(name));
return 0;
}
You see, the longest last name in the world is 588 characters, as
explained here:
http://www.everything2.com/index.pl?node_id=1534419
So, my program works for everyone in the world. Guaranteed.
Exactly how does it ensure that the user is constrained to enter
a genuine last name, and how does it ensure that the constraints
for a longest last name /still hold/ when it runs?
Nice try.
--
Far-Fetched Hedgehog
"It took a very long time, much longer than the most generous estimates."
- James White, /Sector General/
user923005 said:
On Jan 14, 9:27 pm, Billy Bong <billyb655...@aol.comwrote:
<snip>
>printf("Hi %s\n",gets(name)); return 0;
}
You see, the longest last name in the world is 588 characters, as explained here:
http://www.everything2.com/index.pl?node_id=1534419
So, my program works for everyone in the world. Guaranteed.
What if they type in an extra ten letters, just for fun?
What if they feed it a 100 MB binary file?
YHBT.
--
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 <g-******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>user923005 said:
>On Jan 14, 9:27 pm, Billy Bong <billyb655...@aol.comwrote:
<snip>
>>printf("Hi %s\n",gets(name)); return 0;
}
You see, the longest last name in the world is 588 characters, as explained here:
http://www.everything2.com/index.pl?node_id=1534419
So, my program works for everyone in the world. Guaranteed.
What if they type in an extra ten letters, just for fun?
What if they feed it a 100 MB binary file?
YHBT.
Wow. Call the news media. A CLC regular who gets the joke.
This is a truly newsworthy event.
"user923005" <dc*****@connx.comwrote in message
On Jan 14, 9:27 pm, Billy Bong <billyb655...@aol.comwrote:
>I wrote this program which guarantees to use gets safely.
#include <stdio.h> int main(void) { char name[588+1]; printf("Enter your last name: "); fflush(stdout); printf("Hi %s\n",gets(name)); return 0;
}
>You see, the longest last name in the world is 588 characters, as explained here:
>http://www.everything2.com/index.pl?node_id=1534419
>So, my program works for everyone in the world. Guaranteed.
>What if they type in an extra ten letters, just for fun?
>What if they feed it a 100 MB binary file?
If you disobey instructions the program might not work. But that's true of
almost every product.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
"Billy Bong" <bi**********@aol.comwrote in message
news:Zp*****************@newsfe07.lga...
>I wrote this program which guarantees to use gets safely.
The program can't guarantee anything. It's up to the user in this case, and
you can't guarantee what the user will do. But I think you knew that.
I tried your code (using name[5+1] instead to save some typing) with my full
name, and it crashed.
Bart
>
#include <stdio.h>
int main(void)
{
char name[588+1];
printf("Enter your last name: ");
fflush(stdout);
printf("Hi %s\n",gets(name));
return 0;
}
Kenny McCormack wrote:
Wow. Call the news media. A CLC regular who gets the joke.
This is a truly newsworthy event.
Hardly.
--
Nice Try Hedgehog
"Life is full of mysteries. Consider this one of them." Sinclair, /Babylon 5/
In article <uL********************@fe3.news.blueyonder.co.uk> ,
Chris Dollin <eh@electrichedgehog.netwrote:
>Kenny McCormack wrote:
>Wow. Call the news media. A CLC regular who gets the joke. This is a truly newsworthy event.
Hardly.
Such style. Such grace. Such quality of argumentation.
The only thing missing is the obligatory "Neener, neener!".
On 15 Jan 2008 at 19:16, Kenny McCormack wrote:
In article <uL********************@fe3.news.blueyonder.co.uk> ,
Chris Dollin <eh@electrichedgehog.netwrote:
>>Kenny McCormack wrote:
>>Wow. Call the news media. A CLC regular who gets the joke. This is a truly newsworthy event.
Hardly.
Such style. Such grace. Such quality of argumentation.
The only thing missing is the obligatory "Neener, neener!".
Interesting to see Chris "holier-than-thou" Dollin getting his hands
dirty insulting the "trolls" though...
On 15 Jan 2008 at 21:33, Chris Dollin wrote:
Antoninus Twink wrote:
>Interesting to see Chris "holier-than-thou" Dollin
I'm honoured, Antoninus, but I didn't realise you were qualified
to award holiness.
Yes, that did end up sounding much too pejorative! I don't think you're
positively sanctimonius at all - it's just that unlike most of The
Clique you seem quite good-natured and good-humored, and don't usually
go in for the nastiness and acrimony that's the bread and butter of most
of the regulars here.
>getting his hands dirty insulting the "trolls" though...
/That/ was mere snark.
Fair enough. You'd have to agree that CLC is actually one of the most
humorless places on Usenet though...
Antoninus Twink wrote:
On 15 Jan 2008 at 19:16, Kenny McCormack wrote:
>In article <uL********************@fe3.news.blueyonder.co.uk> , Chris Dollin <eh@electrichedgehog.netwrote:
>>>Kenny McCormack wrote:
Wow. Call the news media. A CLC regular who gets the joke. This is a truly newsworthy event.
Hardly.
Such style. Such grace. Such quality of argumentation. The only thing missing is the obligatory "Neener, neener!".
Interesting to see Chris "holier-than-thou" Dollin
I'm honoured, Antoninus, but I didn't realise you were qualified
to award holiness.
getting his hands dirty insulting the "trolls" though...
/That/ was mere snark.
--
Boojum Too Hedgehog
The "good old days" used to be much better.
[snips]
On Tue, 15 Jan 2008 10:26:49 +0000, Malcolm McLean wrote:
>>What if they feed it a 100 MB binary file?
If you disobey instructions the program might not work. But that's true of
almost every product.
Unlike most products, software can cope with such things. A toaster can't
prevent you sticking a fork in it while it's plugged in, even though this
is an undesirable state of affairs, but a program _can_ prevent you
entering incorrect inputs, by avoiding input routines such as gets, and by
validating the data returned by such routines.
Besides, much input to a typical program comes from humans, who are *not*
perfect in their typing, let alone anything else they do. A program which
fails to deal with this reality is doomed to endless errors. A programmer
who fails to deal with this reality is - one would hope - doomed to a
career path not involving software development.
"Malcolm McLean" <re*******@btinternet.comwrote:
"user923005" <dc*****@connx.comwrote in message
On Jan 14, 9:27 pm, Billy Bong <billyb655...@aol.comwrote:
I wrote this program which guarantees to use gets safely.
char name[588+1];
printf("Hi %s\n",gets(name));
You see, the longest last name in the world is 588 characters, as
What if they type in an extra ten letters, just for fun?
What if they feed it a 100 MB binary file?
If you disobey instructions the program might not work. But that's true of
almost every product.
You clearly do not own a pet larger than a budgie, and do not have
little children. Nor do you read reference books while coding.
Richard
Antoninus Twink wrote:
On 15 Jan 2008 at 21:33, Chris Dollin wrote:
>Antoninus Twink wrote:
>>Interesting to see Chris "holier-than-thou" Dollin
I'm honoured, Antoninus, but I didn't realise you were qualified to award holiness.
Yes, that did end up sounding much too pejorative! I don't think you're
positively sanctimonius at all - it's just that unlike most of The
Clique
I think the "clique" is an invention of its detractors.
you seem quite good-natured and good-humored, and don't usually
go in for the nastiness and acrimony that's the bread and butter of most
of the regulars here.
I think you are mistaken.
>>getting his hands dirty insulting the "trolls" though...
/That/ was mere snark.
Fair enough. You'd have to agree that CLC is actually one of the most
humorless places on Usenet though...
I'm afraid I'm under no such obligation.
--
Insufficient Evidence Hedgehog
"A facility for quotation covers the absence of original thought." /Gaudy Night/
On 16 Jan 2008 at 22:00, Chris Dollin wrote:
I think the "clique" is an invention of its detractors.
A rose by any other name...
>you seem quite good-natured and good-humored, and don't usually go in for the nastiness and acrimony that's the bread and butter of most of the regulars here.
I think you are mistaken.
About your being good-natured, or about many regulars' being nasty and
acrimonious, or both?
>>>getting his hands dirty insulting the "trolls" though...
/That/ was mere snark.
Fair enough. You'd have to agree that CLC is actually one of the most humorless places on Usenet though...
I'm afraid I'm under no such obligation.
And in your heart of hearts?
Back to your point (when comparing the trolliness of Default Loser and
Chris Hills) about not only technical contributions being positive,
perhaps you could cite the odd example or two of recent posts from
"Brian" that you *do* consider positive?
"Antoninus Twink" <no****@nospam.invalidwrote in message
news:sl*******************@nospam.invalid...
On 16 Jan 2008 at 22:00, Chris Dollin wrote:
>I think the "clique" is an invention of its detractors.
A rose by any other name...
>>you seem quite good-natured and good-humored, and don't usually go in for the nastiness and acrimony that's the bread and butter of most of the regulars here.
I think you are mistaken.
About your being good-natured, or about many regulars' being nasty and
acrimonious, or both?
>>>>getting his hands dirty insulting the "trolls" though...
/That/ was mere snark.
Fair enough. You'd have to agree that CLC is actually one of the most humorless places on Usenet though...
I'm afraid I'm under no such obligation.
And in your heart of hearts?
Back to your point (when comparing the trolliness of Default Loser and
Chris Hills) about not only technical contributions being positive,
perhaps you could cite the odd example or two of recent posts from
"Brian" that you *do* consider positive?
You rage against Heathfield and his infernal cohort yet do not avail
yourself of chp 8 of Unleashed.
Far funnier is that the Falconer posted a fix for gets, ggets, that
Heathfield had to fix from having a memory leak. Does Heathfield need to be
on everyone's speed dial to prognose memory mgmnt trouble in C?
--
Reagan Revision
To sum up: 1. The cosmos is a gigantic fly-wheel making 10,000 revolutions a
minute. 2. Man is a sick fly taking a dizzy ride on it. 3. Religion is the
theory that the wheel was designed and set spinning to give him the ride.
-- H L Mencken, "Coda," in Smart Set (New York, Dec. 1920; repr. in A
Mencken Chrestomathy, pt. 1, 1949).
Billy Bong wrote:
I wrote this program which guarantees to use gets safely.
#include <stdio.h>
int main(void)
{
char name[588+1];
printf("Enter your last name: ");
fflush(stdout);
printf("Hi %s\n",gets(name));
return 0;
}
You see, the longest last name in the world is 588 characters, as
explained here:
http://www.everything2.com/index.pl?node_id=1534419
So, my program works for everyone in the world. Guaranteed.
What if I fall asleep with my nose falling onto the spacebar?
--
Army1987 (Replace "NOSPAM" with "email") This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marcus |
last post by:
We all know that the "gets" function from the Standard C Library (which
is part of the Standard C++ Library) is dangerous. It provides no
bounds check, so it's easy to overwrite memory when using...
|
by: Teh Charleh |
last post by:
OK I have 2 similar programmes, why does the first one work and the second does
not? Basically the problem is that the program seems to ignore the gets call if
it comes after a scanf call. Please...
|
by: Christopher Benson-Manica |
last post by:
gets() is universally acknowledged to be broken and useless; however,
it is still part of the standard library. Why? Is there enough
conforming code out there using gets() to justify retaining...
|
by: Anthony Irwin |
last post by:
Hi,
I am fairly new to C and all the C books I got talk about gets() but when
I compile it says I should not use gets() because it is dangerous. I
understand that it is dangerous because it...
|
by: ais523 |
last post by:
I was just wondering whether there was a portable way to use gets()
safely, and came up with this:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE* temp;
char buf;
|
by: Cuthbert |
last post by:
After compiling the source code with gcc v.4.1.1, I got a warning
message:
"/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the
'gets' function is dangerous and should not be...
|
by: Xavoux |
last post by:
Hello all...
I can't remind which function to use for safe inputs...
gets, fgets, scanf leads to buffer overflow...
i compiled that code with gcc version 2.95.2, on windows 2000
char tmp0 =...
|
by: jacob navia |
last post by:
In the discussion group comp.std.c Mr Gwyn wrote:
< quote >
.... gets has been declared an obsolescent feature and
deprecated, as a direct result of my submitting a DR about it
(which...
|
by: jayapal |
last post by:
Hi all,
Whenever I use the gets() function, the gnu c compiler gives a
warning that it is dangerous to use gets(). why...?
regards,
jayapal.
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
|
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...
| |