評價: 0 回應: 0 閱覽: 110
置頂

自訂標頭檔

我使用自訂標頭檔給兩個不同的C file用

但是編譯器一直顯示已經被參考

我該如何修改?

程式在編譯時,會顯示已經被參考了

我該怎麼改才對?

#ifndef _S_H
#define _S_H

double A(double);
char *B();

#endif

//enf of header file


//這是source file
#include<stdlib.h>
#include<stdio.h>
#include "sh.h"

double A(double x){
  if(x>0)
    return 0;
  else
    return -1;
}
char *B(){
  char str[50];

  sprintf(str,"Hello world!\n");
  return str;
}

//end of source file


//這是主程式
#include<stdlib.h>
#include<stdio.h>
void p1();
void p2();
int main(){
  p1();
  p2();
  system("pause");
  return 0;
}

//end of main program
//這是p1.cpp
#include<stdio.h>
#include "sh.h"

void p1(){
  A(5.5);
  B();
}

//end of p1.cpp

//這是p2.cpp
#include<stdio.h>
#include "sh.h"

void p2(){
  A(4.5);
}

//end of p2.cpp

 

會員登入 (先登入會員才能回覆留言喔!)

Facebook留言