Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What does this declaration in C mean?

Status
Not open for further replies.

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Hi,

Anyone can tell me the statement bellow:

char Key = KEYPAD_...,z;

The code is like that....

Code:
bit KEYPAD_Scan(char* const pKey)
{
	char Key = KEYPAD_NO_NEW_DATA,z;

	if(K0 == 0) {Key = '0';}
	if(K1 == 0) {Key = '1';}
	if(K2 == 0) {Key = '2';}	
	if(K3 == 0) {Key = '3';}
	if(K4 == 0) {Key = '4';}
	if(K5 == 0) {Key = '5';}	
	if(K6 == 0) {Key = '6';}
	if(K7 == 0) {Key = '7';}

	z = *pKey;
.
.
.

Thanks...
 

JankoMuzyk

Member level 2
Joined
Apr 4, 2005
Messages
42
Helped
5
Reputation
10
Reaction score
0
Trophy points
1,286
Location
Poland
Activity points
1,653
Re: Declaration in C

this is declaration of char type variables 'Key', and 'z', additional 'Key' variable is initialized with KEYPAD_NO_NEW_DATA constant. KEYPAD_NO_NEW_DATA is probably defined with #define KEYPAD_NO_NEW_DATA some_val
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: Declaration in C

Hi,

You are right, KEYPAD_NO_NEW_DATA is define:
#define KEYPAD_NO_NEW_DATA '*'

but i still not understand ,z ?

Please can you explain detail again or give some simple programe. So that i can understand well.....

Thank you
 

Gorilla

Member level 5
Joined
Jan 13, 2003
Messages
89
Helped
9
Reputation
18
Reaction score
0
Trophy points
1,286
Activity points
902
Re: Declaration in C

Code:
char Key = KEYPAD_NO_NEW_DATA,z;

You could also write:

Code:
char Key = KEYPAD_NO_NEW_DATA;
char z;

The comma simply allows you to declare multiple variables of the same type.

So

Code:
char a;
char b;
char c;

a=0;
b=1;
c=2;

and

Code:
char a, b, c;

a=0;
b=1;
c=2;

are the same.
 

    Help

    Points: 2
    Helpful Answer Positive Rating

asahin11

Member level 3
Joined
Jun 20, 2005
Messages
57
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Activity points
1,767
Re: Declaration in C

I think KEYPAD_NO..... is a const variable and programmer initillize Key local variable with KEYPAD_NO..... You should control begining of program for KEYPAD_NO....

best luck
 

waterman

Member level 5
Joined
Mar 27, 2002
Messages
80
Helped
2
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
562
Re: Declaration in C

Key and z are independent from each othe.

Value of Key is assigened by K0~K7, however value of z is assinged directly by the content of pointer pKey
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top