Aravind
Aravind

Reputation: 149

Declaration of char array

I have seen a program, in the header file declared as below

typedef char CHAR10[10];

and in the program as below

CHAR10  szReading;

Is the above declaration same as

char szReading[10];

I am pretty much confused with these. Could someone explain what exactly it is?

Upvotes: 2

Views: 77

Answers (2)

ForceBru
ForceBru

Reputation: 44828

Yes, you understand it correctly. See this answer for more details.

When you say CHAR10 would be the same as an array of char with fixed length and then say CHAR10 test, then test will certainly be an array of char of the length you want (10 in your example).


Examples of typedef usage

typedef unsigned int uint;
uint K; // K is an unsigned int

typedef char *SortOfString;
SortOfString test; // test is a pointer to char

Upvotes: 1

Carl Norum
Carl Norum

Reputation: 224844

Yes, your interpretation is correct.

Upvotes: 1

Related Questions