如何在domaine中检索domain_cx中的数据,一旦我在函数get_domaine(...)中我尝试了以下内容,但结果不是预期的结果(0-2而不是0-2 3).这是我的代码
#include <stdio.h>
#include <stdlib.h>
int get_domaine(char * domaine)
{
char (*ptr_dom)[10];
ptr_dom = (char (*)[10]) domaine;
printf("%s ", ptr_dom[0]); // will print
printf("%s ", ptr_dom[1]); // will not print even thought there is data.
return 1;
}
int main(int argc,char * argv[])
{
char *domaine_cx[10];
domaine_cx[0] = "0-2";
domaine_cx[1] = "3";
if(get_domaine((char *)*domaine_cx)) printf("Ok");
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud) 我想要一个简单的Integer部门,我在Hugs中得到这个
Hugs> :load prog.hs
ERROR file:prog.hs:30 - Instance of Fractional Int required for definition of lastf
Run Code Online (Sandbox Code Playgroud)
我的简单程序是这样的
lastf::Int->Int
lastf 1 = 0
lastf n = if even n then (2*n+1) else (n/2)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么 ?我怎样才能简单地进行划分?