C/C++之Exercise

來源:互聯網
上載者:User

標籤:

一.C/C++之初學Demo、C++調用C、.h檔案使用執行個體:

工程結構:

exercise.h code:

1 #ifndef _EXERCISE_H_2 #define _EXERCISE_H_3 #include <externcpp.h>;4 extern "C"  5 {  6     #include <externc.h>;7 }8 #endif

externc.h code:

1 #ifndef _EXTENC_H_2 #define _EXTENC_H_3 #include <stdio.h>;4 5 void c_hello();6 7 #endif

externcpp.h code:

1 #ifndef _EXTERNCPP_H_2 #define _EXTERNCPP_H_3 #include <iostream>;4 using namespace std;5 6 void cpp_hello();7 8 #endif

c_hello.c code:

1 #include <externc.h>;2 3 void c_hello(){4     printf("C Hello World!");5     getchar();6 }

cpp_hello.cpp code:

1 #include <externcpp.h>;2 3 void cpp_hello(){4     cout<<"C++ Hello World!";5     getchar();6 }

main.cpp code:

1 #include <exercise.h>2 3 void main(){4     c_hello();5     cpp_hello();6 }

二.VS2010及以上之錯誤C1083解決:

 "error C1083"這個錯誤是因為VS中C/C++常規配置中載入標頭檔的路徑問題:

解決方案:

1)右鍵查看該項目的屬性

2)點擊屬性——〉配置屬性  ——〉C/C++  ——〉  常規  ——〉附加元件封裝含目錄 ——〉編輯

3) 添加

$(ProjectDir) // 工程目錄

$(ProjectDir)inc // 工程子目錄

C/C++之Exercise

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.