c++ - 如何将我的 C++ 代码与 Visual Studio C++ 中的表单连接起来?
问题描述
我对这件事真的很陌生,而且我正在迈出第一步,所以这可能是一个愚蠢的问题。我制作了一个在“Dev C++”程序中运行的 .cpp 文件。我需要可视化我的程序的一些结果(图表等),所以我需要以某种方式将我的代码与我在 Visual Studio 中制作的表单连接起来。结果每次都会改变,所以我不能只是手写。我的想法是有一个按钮,当用户单击它时,它将运行我的 c++ 程序,当结果准备好时,它们将在图表上执行。
我的代码现在是这样并且正在运行,但我还没有完成它,因为我现在的主要问题是找到一种从 Visual Studio 运行这个程序的方法,并以某种方式将它与一个按钮连接起来。
我应该调用 eventHandler 还是某事?我应该在我的 .cpp 文件上写一些东西,以便它可以以某种方式与表单连接吗?
使用命名空间标准;
/* 从字符串中提取所有整数 */ void extractIntegerWords(string str) { stringstream ss;
/* Storing the whole string into string stream */
ss << str;
/* Running loop till the end of the stream */
string temp;
int found;
while (!ss.eof()) {
/* extracting word by word from stream */
ss >> temp;
/* Checking the given word is integer or not */
if (stringstream(temp) >> found)
cout << found << " ";
/* To save from space at the end of string */
temp = "";
}
}
//------------------------------------------------ -------------------------------------------
int main(int argc, char** argv) { int i=0,count_elements=0,a=0;
string line;
string keyword[2];
ifstream readyfile("file.map");
ofstream newfile("search_list.txt");
//Give the keywords
keyword[0] = {"Module ro code "};
keyword[1] = {"Grand Total:"};
cout<< endl;
while(getline(readyfile,line))
{
for(i=0;i<2;i++)
{
if (line.find(keyword[i]) != std::string::npos)
{
count_elements++;
int n = line.length();
line.erase(std::remove(line.begin(), line.end(), '\''), line.end());
extractIntegerWords(line);
newfile<<line<<endl;
}
}
}
cout<<"Process has been completed!"<<endl;
cout<<"There have been "<<count_elements<<" elements found and written on the file"<<endl;
readyfile.close();
newfile.close();
system("pause");
return 0;
}
解决方案
推荐阅读
- c# - 如何展平(int,dictionary)的字典?
- python - 即使定义了 Tkinter 中的帧,也无法识别
- node.js - npm - 如果使用 docker 运行,则找不到模块
- c++ - 提升指针的 std::vector 的序列化。错误:“未注册的类 - 未注册或导出的派生类”
- node.js - 对表达做出反应:req.body 未定义
- azure - 我们如何将数据库从 Provisioned CosmosDB 迁移到无服务器 CosmosDB?
- javascript - styled.TouchableOpacity 组件中 props.style 的类型是什么?
- linux - Wifi 站带宽 160MHz / 80MHz 控制 (linux)
- php - 我想根据 if 块中提到的条件将查询分配给 $query 变量,但它给了我一个错误,即提供了 null
- html - 切换侧边栏时如何在导航栏中移动/动画文本值