-1

I'm new to programming and after I have learned the basics of C I don't understand the following keywords:

  1. (*char)
  2. a -> b
  3. char**
shanet
  • 7,246
  • 3
  • 34
  • 46
  • Have you learned the concept of pointers? – Leeor Dec 03 '13 at 20:08
  • I strongly recommend to read a book instead of struggling with the bases of the language. Pick one from http://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list . – Alexandre C. Dec 03 '13 at 20:17

2 Answers2

0

You need a C book! I'll tell you what it means though:

  1. (char) is the char variable type wrapped in parenthesis. You do this when you are typecasting.

  2. a -> b is how you access a structure field if a is a pointer to a structure and b is the variable name of the field.

  3. char * is how you declare something to be a pointer to a char, as in char *c.

They could have other meanings too. Depends on the context.

You edited your question!

  1. (*char) is how you'd dereference a variable named char if you could, but you can't because char is a keyword.

  2. a -> b is how you access a structure field if a is a pointer to a structure and b is the variable name of the field.

  3. char ** is a pointer to a pointer to a char. You see this when you have an array of strings.

Fiddling Bits
  • 8,712
  • 3
  • 28
  • 46
0

In order, they are:

  • dereferenced char pointer (read "value at")

  • b, an element of something pointed to by a

  • A pointer to a char*, or a pointer to a pointer to a char

mfabel
  • 178
  • 1
  • 12
  • Really? The second one is C++ specific? Then how would you access a member of a `struct` in C, given a pointer to that `struct`? – Praetorian Dec 03 '13 at 20:14
  • `a -> b` can be C too. – Fiddling Bits Dec 03 '13 at 20:14
  • @Praetorian: Your third question does not support your implication that `->` is defined in C. (It is, but the third question does not support it.) That is because, if `->` were not defined in C, you would use `(*a).b`. – Eric Postpischil Dec 03 '13 at 20:36
  • I stand corrected; `a->b` is valid C. I always have seen it as `(*a).b`, so I guess I made an invalid assumption. Fixed now. – mfabel Dec 03 '13 at 23:44