[英]error calling a function from main
我试图从一个main函数调用两个函数,我的main函数的代码如下:
#include <watchdoggen.h>
#include <concat.h>
using namespace std;
int main () {
string plain;
char key1[16];
char si[10];
char w[10];
char fid[20];
cout << "Enter the number of splits: ";
cin >> si;
cout << "Enter the number of watchdogs: ";
cin >> w;
cout << "Enter the Fid: ";
cin >> fid;
concat(si, w, fid);
//cout<<"\nThe plain txt is: "<< si <<endl;
plain = si;
cout << "the plaintext is: ";
cin.ignore();
getline(cin, plain);
cout << "Enter the Master Key: ";
cin>>key1;
byte* key_s = (byte*)key1;
cout << "key: " << plain << endl;
watchdoggen(plain,key_s);
}
在这里,我试图基本上将一个函数的输出作为另一个函数的输入。 当我编译代码时,我收到以下错误:
test4watchdoggen.cpp: In function ‘int main()’:
test4watchdoggen.cpp:67:19: error: ‘concat’ was not declared in this scope
我使用以下命令编译:
g++ -g3 -ggdb -O0 -DDEBUG -I/usr/include/cryptopp test4watchdoggen.cpp \
watchdoggen.cpp concat.cpp -o test4watchdog -lcryptopp -lpthread
需要一些帮助。
concat.h
#ifndef TRY_H_INCLUDED
#define TRY_H_INCLUDED
char concat(char si[],char w[],char fid[]);
#endif
include guard用于防止包含相同的头两次:
#ifndef MY_GUARD
#define MY_GUARD
// code ...
#endif
但是这只有在每个标头都有一个唯一的防护名称时才能正常工作。 在您的情况下,两个标头中的警卫都具有相同的名称TRY_H_INCLUDED
,因此包括一个会自动阻止另一个包含。
修复是简单地为每个头文件提供一个包含守卫的唯一名称,正如Hari Mahadevan建议的那样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.