javascript - 如何将 C 程序与 javascript 连接起来?
问题描述
我有一个用 C 编写的模式发现工具程序。它会自动发现模式。我也有一个用 javascript 编写的 web 应用程序。我想在该 Web 应用程序上可视化从该工具收到的数据。我怎样才能将两者连接起来。即 C 程序工具和 javascript 编写的网络应用程序?
解决方案
在您的 C 代码中放入以下行
1. 在 Javascript 中创建一个函数
parser.parse( "function faculty(input) {\n"
" if(input<=1) return 1;\n"
" return input*faculty(input-1);\n"
"}");
context* c=parser.get_context();
从 C++ 调用函数
valueP result = c->global()"faculty";
提取结果(应为 3628800)
int output = unwrap<int>(result)();
推荐阅读
- c++ - 将 char 数组复制到 QByte 数组中,而无需传递指针
- spring-webflow - Webflow 1 到 Webflow 2 迁移 - 警告:不再支持 bean 属性
- swagger - 将 OpenAPI 部署到本地主机
- ubuntu - Cmake外部共享库未在ubuntu上链接
- python - 为什么 [] 和 bool 返回 []?
- node.js - AWS::Lambda 无服务器调用本地函数不反映我的新 wcode
- php - 如何在同一查询中获取实体和计数?
- javafx - javafx SplitPane 分配器在内容/子项更改时跳转
- r - 如何使用两个日期之间的季度序列来旋转表格
- vue.js - Vuejs - 在'this'而不是self中观察嵌套对象