Re: What does the asteriks mean?

Discussion in 'C Programming' started by FakeAddress@NoSpam.com, Jun 26, 2003.

  1. Guest

    >Learn about pointers; then you'll understand what the "*" means.

    >I know that sounds flippant. It isn't meant to be. If you're
    >studying C either by reading a book or by taking a class (assuming in
    >either case that it's a decent one), you'll gain a much better
    >understanding of pointers, and of the language in general, than you
    >can get by asking "what does this mean?" questions here.


    ==========

    I am taking a c programming course right now. In fact, our next topic
    is pointers. We are currently implenting structs in our programs. I
    was told to use the gets function in my program, but after some
    further investigation on the Internet, I discovered that using the
    gets function is not advised. I then looked into using the fgets
    function, but found that it reads in the new line. I then began to
    look for a work around. I understood what was going on in the code
    that I posted. I just wanted to know more about the asterisk/pointer.
     
    , Jun 26, 2003
    #1
    1. Advertising

  2. Simon Biber Guest

    <> wrote:
    > I am taking a c programming course right now. In fact, our next
    > topic is pointers. We are currently implenting structs in our
    > programs. I was told to use the gets function in my program,
    > but after some further investigation on the Internet, I
    > discovered that using the gets function is not advised. I then
    > looked into using the fgets function, but found that it reads
    > in the new line. I then began to look for a work around. I
    > understood what was going on in the code that I posted. I just
    > wanted to know more about the asterisk/pointer.


    If your programming course tells you to use gets, then everything
    they say is immediately suspect. I would be very careful about
    anything they teach you there -- it may be full of other very bad
    practises.

    I assume you have found out exactly why using gets is not advised?
    It gives you no way to control how much data might be read in to
    the given array. Not only is it 'undefined behaviour' to write
    data outside the allocated space, in practise it can do very bad
    things to the computer. Buffer overflows are one of the most common
    ways to successfully break in to computer systems, as you can
    essentially write whatever data you want into the memory space
    then the computer may execute that data as code.

    --
    Simon.
     
    Simon Biber, Jun 26, 2003
    #2
    1. Advertising

  3. Tom St Denis Guest

    Re: [OT] Re: What does the asteriks mean?

    dbtid wrote:
    > On Thu, 26 Jun 2003 12:14:26 +1000, Simon Biber
    > <> wrote:
    >
    >> <> wrote:
    >>
    >>> I am taking a c programming course right now. In fact, our next
    >>> topic is pointers. We are currently implenting structs in our
    >>> programs. I was told to use the gets function in my program,
    >>> but after some further investigation on the Internet, I
    >>> discovered that using the gets function is not advised. I then
    >>> looked into using the fgets function, but found that it reads
    >>> in the new line. I then began to look for a work around. I
    >>> understood what was going on in the code that I posted. I just
    >>> wanted to know more about the asterisk/pointer.

    >>
    >>
    >> If your programming course tells you to use gets, then everything
    >> they say is immediately suspect. I would be very careful about
    >> anything they teach you there -- it may be full of other very bad
    >> practises.

    >
    >
    > I'm amazed that you could reach such an astounding conclusion without
    > knowing ANYTHING about the OP's course.
    >
    > Your lack of foresight is astounding.
    >
    > Without knowing anything about the *rest* of the class,
    > this response is unfair to the instructor and presumptuous.


    I attend "Algonquin College" in Ottawa [for the curious]...

    And I agree with the OP. I was "taught" to use things like gets, scanf,
    etc... almost religiously.

    I even got docked marks when I used a combo of fgets/sscanf [with proper
    return checking] to read integers once. Naturally I explained the error
    of the teachers ways but that doesn't stop them from teaching it.

    Most of my teachers are dumbfounded when I explain to them getting
    rooted is a bad thing for a hello world app.

    Right from the get-go I think students should be taught what functions
    like gets/scanf are and exactly why to avoid them. Good habits start early.

    And remember, Smokey says only you can stop forrest fires. Unless you
    live in the US and are an environmentalist. In that case you're a
    fucking idiot and caused the wildfires by putting out previous fires
    which would have got gid of the underbrush..... sucker!

    Tom
     
    Tom St Denis, Jun 26, 2003
    #3
  4. dbtid Guest

    [OT] Re: What does the asteriks mean?

    On Thu, 26 Jun 2003 12:14:26 +1000, Simon Biber <>
    wrote:

    > <> wrote:
    >> I am taking a c programming course right now. In fact, our next
    >> topic is pointers. We are currently implenting structs in our
    >> programs. I was told to use the gets function in my program,
    >> but after some further investigation on the Internet, I
    >> discovered that using the gets function is not advised. I then
    >> looked into using the fgets function, but found that it reads
    >> in the new line. I then began to look for a work around. I
    >> understood what was going on in the code that I posted. I just
    >> wanted to know more about the asterisk/pointer.

    >
    > If your programming course tells you to use gets, then everything
    > they say is immediately suspect. I would be very careful about
    > anything they teach you there -- it may be full of other very bad
    > practises.


    I'm amazed that you could reach such an astounding conclusion without
    knowing ANYTHING about the OP's course.

    Your lack of foresight is astounding.

    Without knowing anything about the *rest* of the class,
    this response is unfair to the instructor and presumptuous.

    It may the the instructor has a *really good reason* for allowing
    the students to use gets for a little bit, only to turn around and
    show them how it's going to bite them in the ass if they use it
    in a real program in the real world... and then shows them that the
    solution is this great thing called fgets.

    Or maybe he's going to use it in a way to cause the students to
    come up with a "better" gets, leading them to fgets.

    Get off your high horse.
     
    dbtid, Jun 26, 2003
    #4
  5. Tom St Denis Guest

    Re: [OT] Re: What does the asteriks mean?

    dbtid wrote:

    > They have their place in instruction. Look how far the original
    > authors of C got with them... but they were careful programmers. So
    > certainly
    > it's not a great idea to encourage newbies to use them without discretion.
    >
    > Why, just yesterday, I wrote a program that uses fscanf.
    >
    > But *I* produced the output, and *I* knew exactly what went where, and I
    > made sure that I matched things up properly. No one else is going to use
    > this program ever again; it was a once-in-a-lifetime sanity check on
    > something else I was doing, and fscanf happened to be the most useful tool
    > in my toolbox for quickly and easily verifying something.


    It's all about habits. If you spend more than 10 minutes writing the
    program you shouldn't use them. For example, occasionally I'll need
    some table or something. I'll spend 5 mins, hack out really horrible
    code and get the table I need.

    But for anything else you ought to use better functions even if you
    control the input/output.

    >> I even got docked marks when I used a combo of fgets/sscanf [with
    >> proper return checking] to read integers once. Naturally I explained
    >> the error of the teachers ways but that doesn't stop them from
    >> teaching it.
    >>

    >
    > That's a shame. An instructor should be open enough (and smart enough,
    > and know the language & the libraries well enough) to recognize something
    > better when they see it. Yours was a poor instructor in that regard.


    Not so much as "poor instructor" but "set in their ways". They have
    been teaching the class the same way for ages and don't feel up to
    listening to the remarks of a mere student.

    That is another issue though. Most students I hang out with often
    notice errors in the lectures as well [specially when dealing with
    computer parts, or languages such as C or C++] but don't bring up the
    errors for fear of getting lower marks.

    >> Most of my teachers are dumbfounded when I explain to them getting
    >> rooted is a bad thing for a hello world app.

    >
    >
    > LOL... I'd like to hear more about the particulars there.


    It was one of our first C apps, [well not mine, I mean first in the
    college program]. I don't remember the exact details but I think we had
    to read in customers names, balances, etc and display them nicely.

    Anyways, the typical bs was to gets the name, fflush(stdin) and scanf
    the balance.

    I wrote mine with fgets and sscanf [with the appropriate loops to get
    the input]. The teacher asked me why I didn't follow the "hints" he so
    graciously offered. I simply replied I didn't wany my app to get rooted
    [well not likely for this app, but you know what I mean].

    I actually had to sit and explain how the stack [in this case on an x86]
    worked and how an attacker could place code on the stack and take
    control of the application.

    > Right from the get-go I think students should be taught what functions
    >> like gets/scanf are and exactly why to avoid them. Good habits start
    >> early.
    >>

    >
    > Agreed. But how do you or I or Simon know what the instructor was going
    > to do *NEXT*??? That's the whole point of what I wrote.
    >
    > MAYBE the instructor is just going to go on blindly teaching to use gets,
    > as your instructor seemed to do. OK: BAD BOY! NO MORE COMPUTER ACCESS
    > UNTIL
    > YOU WRITE 5,000 TIMES: "GETS() IS EVIL. I WILL NOT TEACH OTHERS TO USE IT
    > WITHOUT EXPLAINING THAT IT CAN BE VERY DANGEROUS AND THERE ARE BETTER
    > ALTERNATIVES!!"
    >
    > That might even be fun! :)
    >
    > But we simply don't know. And not having information does not justify
    > such a conclusion. At best we can be suspicious and point out our
    > reasons for suspicion, but to blindly attack the instructor know does
    > the OP no good.


    True enough. I think it was just realistic cynisms [sp?]. All too many
    of my college profs are just brain-dead idiots they dragged off the
    streets. Some are highly arrogant SOBs, like my networking teacher who
    insists on teaching how to setup IPXODI and Novell because they are
    "leading edge".

    Only once in a while you will run into prof's who are truly in their
    game. But since they are far and few between I can see how people have
    a bleak outlook.

    Tom
     
    Tom St Denis, Jun 26, 2003
    #5
  6. Re: [OT] Re: What does the asteriks mean?

    On Thu, 26 Jun 2003 14:02:37 GMT, in comp.lang.c , dbtid
    <> wrote:

    >On Thu, 26 Jun 2003 12:14:26 +1000, Simon Biber <>
    >wrote:
    >
    >> If your programming course tells you to use gets, then everything
    >> they say is immediately suspect. I would be very careful about
    >> anything they teach you there -- it may be full of other very bad
    >> practises.

    >
    >I'm amazed that you could reach such an astounding conclusion without
    >knowing ANYTHING about the OP's course.

    ....
    >Without knowing anything about the *rest* of the class,
    >this response is unfair to the instructor and presumptuous.


    A gun instructor who told you all the right ways to shoot, clean and
    store guns, but then told you to check for rounds in the chamber by
    looking down the barrel, would still be a bad instructor, despite all
    his good points.

    gets() is a loaded gun. Don't look down the barrel.

    >It may the the instructor has a *really good reason* for allowing
    >the students to use gets for a little bit,


    yeah, like teaching people to scuba-dive by tying weights to their
    ankles and throwing them in the deep end with an aqualung just out of
    reach... :)


    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
     
    Mark McIntyre, Jun 26, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom St Denis

    Re: What does the asteriks mean?

    Tom St Denis, Jun 26, 2003, in forum: C Programming
    Replies:
    1
    Views:
    808
  2. Dan Pop

    Re: What does the asteriks mean?

    Dan Pop, Jun 26, 2003, in forum: C Programming
    Replies:
    0
    Views:
    670
    Dan Pop
    Jun 26, 2003
  3. Re: What does the asteriks mean?

    , Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    589
    Keith Thompson
    Jul 8, 2003
  4. Li Ma
    Replies:
    1
    Views:
    2,282
    Roedy Green
    Mar 9, 2009
  5. C Barrington-Leigh
    Replies:
    1
    Views:
    1,209
    Tim Leslie
    Sep 10, 2010
Loading...

Share This Page