相关疑难解决方法(0)

Writing a generic function in C, how to handle strings

I have a function that takes a void** argument and an integer that indicates its datatype

void foo (void** values, int datatype)
Run Code Online (Sandbox Code Playgroud)

Inside the function, depending on the datatype, I malloc it this way:

if (datatype == 1)
    *values = (int*) malloc (5 * sizeof(int));
else if (datatype == 2)
    *values = (float*) malloc (5 * sizeof(float));
Run Code Online (Sandbox Code Playgroud)

All is good upto now. However, when character strings come into the picture, things get complicated. The void** would need to be void*** …

c

13
推荐指数
3
解决办法
785
查看次数

Fortran 中的可变长度参数列表?

Fortran 是否曾经像 C 那样处理任意长度的子例程参数列表?(顺便说一句,“礼物”对我想做的事情不起作用。)谢谢。

fortran arguments subroutine

6
推荐指数
1
解决办法
1102
查看次数

标签 统计

arguments ×1

c ×1

fortran ×1

subroutine ×1