2014-03-27 18 views
0

我想打電話從一個主要功能兩個功能我主要FUNC的代碼如下功能:錯誤調用從主

#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 
+2

歡迎來到Stack Overflow。請儘快閱讀[關於]頁面。 ''標題中有什麼? AFAIK,它不是一個標準的頭文件,但它的名字暗示了''concat()'函數可能來自哪裏。在你的代碼中,如果聲明瞭'concat()',那麼輸出的位置就不清楚了。 –

+0

你有一些聽起來相似但又不同的東西的組合,當一起使用時會給你很多問題。爲什麼不使用char []或字符串,但不是兩個? – carlosdc

+0

深入瞭解''水箱內...檢查'CONCAT()'你試圖調用函數是存在的,不存在'#if'可能從翻譯單元被移除的語句,以及它是否在您需要用來調用它的名稱空間中。 (或者 - 更好有時 - 你可以調用編譯器'G ++ -E -DDEBUG -I/usr/include目錄/ cryptopp test4watchdoggen.cpp watchdoggen.cpp concat.cpp'和檢查後預處理代碼,以確保該函數的有預期)。 –

回答

2

include guard用於防止包括兩次相同的標題:

#ifndef MY_GUARD 
#define MY_GUARD 
// code ... 
#endif 

但這只是正常工作,如果每頭有保護的唯一名稱。在你的情況下,你的頭文件中的守衛具有相同的名字TRY_H_INCLUDED,所以包括一個自動防止另一個被包括在內。

修復的方法是簡單地給每個頭文件的包括防護品哈日馬哈德唯一的名稱建議。