请问如何在Fortran里面调用C函数??

ctech ctech 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是 .c 文件
——————————————————————————————————
#include <stdio.h>
#include <sys/sysinfo.h>
#include <stdlib.h>

void show ()
{
struct sysinfo info;
unsigned long ram_total = 0, ram_used = 0, swap_total = 0, swap_used = 0;
int mem_unit;

sysinfo(&info);

mem_unit = info->mem_unit;

ram_total = info.totalram * mem_unit / 1024000;
ram_used = ram_total - info.freeram * mem_unit / 1024000;
swap_total = info.totalswap * mem_unit / 1024000;
swap_used = swap_total - info.freeswap * mem_unit / 1024000;

printf("系统共有内存%ldMb, 已用%ldMb, 共有交换分区%ldMb, 已用%ldMb\n",
ram_total, ram_used, swap_total, swap_used);

return;
}
——————————————————————————————————————————


这是.f90文件

program main

call show()

end program main


请问如何做才能在fotran文件里调用上面.c文件里的show()函数呢???谢谢!
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
ctech
C语言 70,039 成员 243,237 内容