我非常精通在F#中使用>>和<<运算符.然而,在查看F#源以建立更深入的理解之后,我对此感到困惑:
let inline (>>) f g x = g(f x)
let inline (<<) f g x = f(g x)
Run Code Online (Sandbox Code Playgroud)
我如何从概念上解释这些表达?另外,你会如何形容这些表达?他们定义了一种类型吗?
typedef struct {
char * array[10];
} List;
int main(void) {
List input;
input.array = (char **)malloc(10 * sizeof(char));
if (input.array == NULL)
exit(EXIT_FAILURE);
for (i = 0; i < 10; i++) {
input.array[i] = (char *)malloc(10 * sizeof(char));
if (input.array[i] == NULL)
exit(EXIT_FAILURE);
}
}
Run Code Online (Sandbox Code Playgroud)
我试图初始化一个10个char指针的数组,每个指针指向一个长度为10的不同字符串.
我从gcc收到以下错误:
incompatible types when assigning to type ‘char *[10]’ from type ‘char **’
Run Code Online (Sandbox Code Playgroud)
我对malloc的调用一定不正确,但是怎么回事?