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.

[PIC] Mikroelektronika MikroC

Status
Not open for further replies.

Adamsonics

Newbie
Joined
Aug 29, 2015
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
31
Hello Guys,

Please, I want someone to help me explain the meaning and uses of the following codes if possible with example:

(1) char old state = 0
(2) char oldstate2 = 0
(3) char oldstate = 1
(4) oldstate = 0
(5) oldstate = 1
(6) oldstate++;
(7) enum outputs {UTILITY_GEN = 0,GEN2_SHUTOFF = 1,GEN1_GEN2 = 2};
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,430
Helped
14,252
Reputation
28,765
Reaction score
12,944
Trophy points
1,393
Location
Bochum, Germany
Activity points
280,238
There's nothing mikroC specific with your specification, just plain C language. Any C text book or tutorial has the answer.
I'm still using Kernighan + Ritchie, The C Programming Language.
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,260
Helped
380
Reputation
760
Reaction score
376
Trophy points
83
Activity points
13,632
As written (1) will generate a syntax error as there is a space between "old" and "state".
Similarly, (1) to (5) are all missing the trailing semicolon but that could simply be a transcription error.
If (1) and (3) appear in the same source file (as seen by the compiler) at the same level, and the error I mentioned above is corrected for (1), then the compiler will complain of a duplicate definition. However without seeing the code snippets in context it is almost impossible to tell.
Susan
 

Adamsonics

Newbie
Joined
Aug 29, 2015
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
31
Thank you FvM and Aussie Susan for your response. Please, what I want is the meaning and how to use the undermentioned codes. I have read some books but I couldn't comprehend their meaning and uses. Guys, kindly assist me with their meaning, uses and if possible with example:

(1) char oldstate = 0;
(2) char oldstate2 = 0;
(3) char oldstate = 1;
(4) oldstate = 0;
(5) oldstate = 1;
(6) oldstate++;
(7) enum outputs {UTILITY_GEN = 0,GEN2_SHUTOFF = 1,GEN1_GEN2 = 2};
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
19,777
Helped
4,350
Reputation
8,709
Reaction score
4,314
Trophy points
1,393
Activity points
130,886
Hi,

It seems to be very basic problem (that I actually don't see)

I'm not familiar with C, but I try to describe. (Any C specialist please correct any mistakes.)

Example:
"char oldstate = 0; "
The whole line is a variable declaratio with default value setup
* "char" is a variable type. Character = one byte
* "oldstate" is the variable name
* "=" is the operator to initialize the variable with a value
* "0" is the initial value of the variable.

Klaus
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,430
Helped
14,252
Reputation
28,765
Reaction score
12,944
Trophy points
1,393
Location
Bochum, Germany
Activity points
280,238
1-3 variable declarations with initialisation
4-5 simple variable assignments to constant values
6 variable increment operation
7 declaration of a variable of the enum type

Examples and further explanations are in the above mentioned books.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top