Array

R

raghu

What is the difference between
char a[10];
and
typedef character char [10]
character a;
 
E

Eric Sosman

What is the difference between
char a[10];
and
typedef character char [10]
character a;

One compiles, the other does not.

Perhaps for the second you meant

typedef char character[10]; // words reversed, ; added
character a;

If so, the only difference is the way you spelled your code:
In both cases, `a' is an array of ten `char'.
 
E

Ersek, Laszlo

What is the difference between
char a[10];
and
typedef character char [10]
character a;

One compiles, the other does not.

Perhaps for the second you meant

typedef char character[10]; // words reversed, ; added
character a;

If so, the only difference is the way you spelled your code:
In both cases, `a' is an array of ten `char'.

A weakly related earlier thread ("How is const applied to a pointer
declared in a function parameter"):

http://groups.google.com/group/comp.lang.c/browse_thread/thread/466bf8ae666a4518/

(I remembered it because of the array typedef, sorry if it's completely
irrelevant.)

lacos
 
N

Nick Keighley

What is the difference between
char a[10];
and
typedef character  char [10]
character a;

even after your syntax errors are corrected it might be worth pointing
out you hardly ever want an array to be hidden in a typedef
 
B

Ben Bacarisse

Nick Keighley said:
What is the difference between
char a[10];
and
typedef character  char [10]
character a;

even after your syntax errors are corrected it might be worth pointing
out you hardly ever want an array to be hidden in a typedef

You may be right. I offer this because I've seen it -- I am in two
minds about the value of it:

typedef struct some_huge_structure a_thing[1];

The result is an object type ('a_thing') that can be declared and
initialised almost like any other:

a_thing my_thing = {0}, my_result;

but which gets passed as a pointer without any special action:

thing_function(my_thing, my_result);

Apart from being "tricksy" it suffers from the problem that you can't
return a_thing from a function, but when an API uses the return for
error signalling, this is less of a issue.
 
R

raghu

What is the difference between
char a[10];
and
typedef character  char [10]
character a;

     One compiles, the other does not.

     Perhaps for the second you meant

        typedef char character[10];  // words reversed, ; added
        character a;

If so, the only difference is the way you spelled your code:
In both cases, `a' is an array of ten `char'.

your are right. I was in a hurry. Sorry about that.
 
E

Eric Sosman

What is the difference between
char a[10];
and
typedef character char [10]
character a;

One compiles, the other does not.

Perhaps for the second you meant

typedef char character[10]; // words reversed, ; added
character a;

If so, the only difference is the way you spelled your code:
In both cases, `a' is an array of ten `char'.

your are right. I was in a hurry. Sorry about that.

Perhaps your next hasty, sloppy question will get a hasty,
sloppy answer.

Sorry about that.
 

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

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,220
Latest member
AugustinaJ

Latest Threads

Top