Pages: [1]   Go Down
Author Topic: (char)n vs char(n)  (Read 292 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Bald-Headed, Middle-Aged Nerd
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the difference (if any) between (char)n and char(n) ?
The test code below produces:

88
X
88
X
88

No apparant difference between lines 3 and 5.

Thanks.
Bob W.

Code:
int n = 88;
Serial.println( n );
Serial.println( char(n) );
Serial.println( n );
Serial.println( (char)n );
Serial.println( n );
Logged

Netherlands
Offline Offline
Full Member
***
Karma: 3
Posts: 106
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

'(char)n' is the old C notation; 'char(n)' is C++s functional cast notation; both do exactly the same thing.

kind regards,

Jos
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Bald-Headed, Middle-Aged Nerd
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Jos !
Bob W

'(char)n' is the old C notation; 'char(n)' is C++s functional cast notation; both do exactly the same thing.

kind regards,

Jos
Logged

Pages: [1]   Go Up
Jump to: