-
Help
I've got an exercise due that make no sence to me can someone please explain this to me.
The assignment says given the following definition statement
char k, *p, n[3], **q, *x[4];
What is the data type for the following expressions
Note: Each expression is an rvalue (a constant)
k p
k+2 p+2
&k &p
&k+2 p[2]
and the list goes on
I understand char k= 'k' is a char but what about k+2 ?
If your creating char variable wouldn't they all be char
Help Please
-
I don't understand your examples...
k+2 is 'm' because k contains 'k' and 'k' (which is 107) plus 2 is 109 (which is 'm')
char and int are the same, there are only interpreted differently!
p+2 is a pointer operation!
for example p is a pointer to a string "Hello World"
than p+2 would return "llo World"!
It just adds 2 to the offset...
&k returnes the offset of k!
&k+2
is just the same as p+2 becasuse &k is a offset and you add 2 to the offset...
and *(p+2) or p[0] are exactly the same!
-
Please, for the love of god, post descriptive titles. "Help" doesn't give the reader very much information, and it sucks when you're searching the board and can't find what you want because everything is CALLED HELP FOR ****S SAKE
-
ok bunny I'll change my tiltle, thanks for all your help!!
-
Thats the problem Shade I don't really understand the the problem either. If its k+2 is it still a char because it started out as char ?