Given a base type
T, this can be augmented with
, each meaning pointer and array. For example,
*T means "array of pointer to
*T means "pointer to array of
 type modifiers. C has a way of ordering these modifiers tied to the evaluation order.
*T in C-style becomes
T *, and
T (*). You may be able to understand how the conversion works by having a look at the examples below. An explanation is also given at the end of this post.
* -> *  ->  * -> * * -> (*) ** -> *(*) * -> (*) ** -> *(*) ** -> (**) ** -> *(*) ** -> (*(*))
Your program or function should process an input string to an output string as the examples above. The input will only contain
 without whitespaces.
This challenge is this challenge in reverse, simplified.
Rules for C-fix:
- All of the
*s always come before all of the
s (in real C code, the variable name comes between the last
*and the first
- Evaluation starts in the middle, where the variable name would be.
- If there is both a
*on the left and a
on the right, without any parentheses to determine the order, the
is bound first, and comes first in prefix:
ais the variable name) = "array of pointers" =
- In order to change the order of evaluation so that a
*gets bound first, it must be put in parentheses (with where the variable name would be):
= "pointer to an array" = C
ais the variable name) =
From the last example,
(*(*)) in actual C code would be something like
int (*(*a)) (where
a is the variable name). The evaluation starts from
 is bound first unless a set of parentheses blocks the binding.
If you put
int (*(*a)) to cdecl.org, the output is "declare a as pointer to array of pointer to array of int". This is because:
- The first
*is bound first due to the parentheses.
- There are no parentheses between the variable name and the
, causing that to be bound before the next
- Then, the next
*is bound because it is in the parentheses with the variable name, whereas the remaining
- Finally, the remaining
**int a in prefix. Hence,
** -> (*(*)).