what is the difference between field and variable?

R

root

Hello!

Can somebody explain the difference between fields and variables.
For me they are more or less the same.
Two words for the same thing

//Tony
 
E

Eric Sosman

root said:
Hello!

Can somebody explain the difference between fields and variables.
For me they are more or less the same.
Two words for the same thing

Are you, by any chance, asking about C++ rather than
about C? C uses "field" only in the context "bit-field"
and in the description of some I/O functions, so if you're
asking about "fields" in C you'll first have to tell us
what "fields" are (and the telling you will probably answer
your own question).

But if it's a C++ thing, try comp.lang.c++ instead.
 
D

Default User

root said:
Hello!

Can somebody explain the difference between fields and variables.
For me they are more or less the same.
Two words for the same thing

It's sometimes used to refer to member variables of a struct. In that
case, it's a subset of the larger class of variables.

As Ian said, you'd need to provide more context.




Brian
 
K

Keith Thompson

Default User said:
It's sometimes used to refer to member variables of a struct. In that
case, it's a subset of the larger class of variables.

Though "member variables" are more commonly referred to (at least in
C) as "members".

Whether a struct member is a "variable" depends on (a) how you define
the word "variable", and (b) whether you're referring to it in the
context of the struct type or of an object of the struct type.
As Ian said, you'd need to provide more context.

Yup.
 
M

Michael Angelo Ravera

Hello!

Can somebody explain the difference between fields and variables.
For me they are more or less the same.
Two words for the same thing

In the abstract computing science use of the term, "field" refers to a
congiguous portion of a record. In C records are often represented by
structs, so a field may very well be represented by a portion of a
struct.

In the abstract computing science use of the term, "variable" is any
value that is not a constant (and thus cannot reside permanently and
exclsively in code space).

So, a field implies, but does not require, some higher level of
organization (such as a record) and implies, but does not requre, some
lower level of organization (such as a variable).

Variables may be scalar, vectors, matrices, bases, or higher
organizations of any of these and may be homogeneous or heterogenous
variations of any of these. One might legitimately use the term
"field" to describe one section of a heterogeneous vector (or even one
slab of a homogeneous basis).

All that having been said, the most common use of the term "field" in
C will occur with reference to a character array within a struct.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,251
Members
46,849
Latest member
SabaaKhaan

Latest Threads

Top