Reputation: 3
I am trying to call two functions from one main function the code of my main func is as follows:
#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);
}
Here I am trying to basically give the output of one function as the input of the other function. When I compile the code, I get the following error:
test4watchdoggen.cpp: In function ‘int main()’:
test4watchdoggen.cpp:67:19: error: ‘concat’ was not declared in this scope
I am using the following command to compile :
g++ -g3 -ggdb -O0 -DDEBUG -I/usr/include/cryptopp test4watchdoggen.cpp \
watchdoggen.cpp concat.cpp -o test4watchdog -lcryptopp -lpthread
Need some help on this.
concat.h
#ifndef TRY_H_INCLUDED
#define TRY_H_INCLUDED
char concat(char si[],char w[],char fid[]);
#endif
Upvotes: 0
Views: 276
Reputation: 8956
The include guard is used to prevent including the same header twice:
#ifndef MY_GUARD
#define MY_GUARD
// code ...
#endif
But this only works correctly if each header has a unique name for the guard. In your case, the guards in both of your headers have the same name TRY_H_INCLUDED
, so including one automatically prevents the other from being included.
The fix is to simply give each header file a unique name for the include guard as Hari Mahadevan suggested.
Upvotes: 2