Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #43176

Re: memset

From Richard <rgrdev_@gmail.com>
Newsgroups comp.lang.c
Subject Re: memset
Date 2014-04-20 14:35 +0100
Organization http://www.ieee.org/
Message-ID <87ppkcrune.fsf@gmail.com> (permalink)
References <lihum0$4k0$1@dont-email.me> <10bac1fc-2d9a-49e7-b4c3-0db6f6013b5a@googlegroups.com> <lj0hc9$o2v$1@dont-email.me>

Show all headers | View raw


"Bill Cunningham" <nospam@nspam.invalid> writes:

> Michael Angelo Ravera wrote:
>
>> OK. Your fundamental lack of understanding is that of data
>> representation. Programming in C is designed for people who
>> understand data representation and not for people who don't.
>>
>> What's a pointer? A pointer is a value that represents where
>> something is stored.

You have to say "represents" dont you? Why not just say it points to
where the data is? Sheesh.

>>
>> For most (it is intended and they are working on "all") data items in
>> C, there is a way to obtain a pointer to it. This is often referred
>> to as "dereferencing". For most pointers, there is a way to obtain

NO it isnt. It's called referencing. Dereferencing is obtaining the data
from the location pointed to by the pointer.

https://en.wikipedia.org/wiki/Dereference_operator

When being surly and elite and putting people down it's frequently better
not to get wrapped up in your own twaddle.

>> the data (or first item of data) to which it points, if such a
>> reference would refer to something in the representation (otherwise
>> you will have some kind of a problem -- ranging from "that's not what
>> I meant" on up to "halt and catch fire".)
>>
>> So, let's look at memset: The first argument is a pointer to the
>> beginning of the of the area of memory that you want to set to the
>> particular value.
>> This area may represent an array, a structure, a single data item
>> ("scalar"), or a memory map of some device. The function doesn't know
>> or really care all that much. If you tell it to blast '*'s to the
>> memory map of a printer and your program has proper access to it, you
>> will probably get a bunch of '*'s on the paper (or whatever the '*'s
>> represent to the printer). The function memset just puts however many
>> copies you say of whatever character you say in an area of memory
>> that you say. It doesn't know what it is doing or whether it is doing
>> what you want. It is very much like a screwdriver -- really good for
>> tightening or removing screws, usable for drilling holes, can be made
>> to pry things off of each other, really bad for jamming into your
>> eye.
>>
>> So, the trick in getting memset to do what you want (like putting
>> spaces into a character array where you are going to place a name of
>> something, or putting '*'s into any eye catcher string), is to obtain
>> a pointer to the beginning of the area, determining to what value you
>> want to set everything, and obtaining a byte count for the thing that
>> you want to set.
>>
>> Usually, you can obtain a pointer to the beginning of the
>> representation of something simply dereferencing it with the "&"
>> operator and you can obtain the size of the representation of the
>> that thing by using either "sizeof" or, with some more complicated
>> things, by using "offsetof". But, you need to supply sizeof with the
>> representation of the entire thing that you want to set. In some
>> cases, you will use offsetof (thing,
>> last_variable_thing[number_of_last_variable_things]).
>
>     Thanks Michael but I will have to admit; a lot of this is a little over 
> my head right now. There's just something about these pointers. But I guess 
> that's a common problem with persons who use C. I am a hobbyist. I have been 
> trying to learn C on and off for a long time. I take a break for a while and 
> I am finding learn as you go seems to slowly work. I appreciate any help 
> though. It doesn't go unnoticed.
>
> Bill
>

No. It doesn't ... lol.


-- 
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-14 20:32 -0400
  Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-14 20:40 -0400
    Re: memset glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-15 02:11 +0000
      Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-14 22:22 -0400
      Re: memset Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-04-15 21:07 +0100
  Re: memset Barry Schwarz <schwarzb@dqel.com> - 2014-04-14 21:48 -0700
    Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-15 09:28 -0400
      Re: memset David Brown <david.brown@hesbynett.no> - 2014-04-15 16:07 +0200
        Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-15 21:03 -0400
          Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-15 21:06 -0400
          Re: memset glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-16 01:25 +0000
            Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-15 21:36 -0400
  Re: memset Michael Angelo Ravera <maravera@prodigy.net> - 2014-04-18 13:50 -0700
    Re: memset Kaz Kylheku <kaz@kylheku.com> - 2014-04-18 21:04 +0000
    Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-20 09:16 -0400
      Re: memset Richard <rgrdev_@gmail.com> - 2014-04-20 14:35 +0100
        Re: memset Kaz Kylheku <kaz@kylheku.com> - 2014-04-20 14:10 +0000
          Re: memset gazelle@shell.xmission.com (Kenny McCormack) - 2014-04-21 05:17 +0000
        Re: memset gazelle@shell.xmission.com (Kenny McCormack) - 2014-04-20 15:11 +0000
          Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-22 14:20 -0400
            Re: memset "Osmium" <r124c4u102@comcast.net> - 2014-04-22 14:22 -0500
              Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-22 17:33 -0400
              Re: memset Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-04-25 12:12 +0000
          Re: memset Michael Angelo Ravera <maravera@prodigy.net> - 2014-04-22 15:23 -0700
            Re: memset James Kuyper <jameskuyper@verizon.net> - 2014-04-23 11:39 -0400
              Re: memset "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-24 21:19 -0400

csiph-web