Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
About typedef
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
bindiya182003
New Member
Join Date:
Oct 2007
Posts:
16
#1
About typedef
Oct 7 '07, 06:48 AM
Can anyone tell me the use of typedef in C
What will this statement do:
typedef unsigned char byte;
plz help me......
JosAH
Recognized Expert
MVP
Join Date:
Mar 2007
Posts:
11453
#2
Oct 7 '07, 07:47 AM
Originally posted by
bindiya182003
Can anyone tell me the use of typedef in C
What will this statement do:
typedef unsigned char byte;
plz help me......
Think of an ordinary variable definition; e.g.
[code=c]
int i;
char* p;
[/code]
This defines two variables 'i' and 'p'. Now prepend them with the 'typedef' keyword:
[code=c]
typedef int i;
typedef char* p;
[/code]
Now you have to aliases 'i' and 'p' for the typed 'int' and 'char*' so you may now
use them as:
[code=c]
i ii; // an int
p pp; // a char*
[/code]
kind regards,
Jos
Comment
Post
Cancel
bindiya182003
New Member
Join Date:
Oct 2007
Posts:
16
#3
Oct 7 '07, 08:41 AM
Thanks a lot for your answer...One more doubt How are the datatypes char and unsigned char different
Comment
Post
Cancel
JosAH
Recognized Expert
MVP
Join Date:
Mar 2007
Posts:
11453
#4
Oct 7 '07, 08:49 AM
Originally posted by
bindiya182003
Thanks a lot for your answer...One more doubt How are the datatypes char and unsigned char different
I already answered that question in your other thread.
kind regards,
Jos
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment