码迷,mamicode.com
首页 > 编程语言 > 详细

C/C++之Exercise

时间:2015-03-18 12:03:38      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

一.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

标签:

原文地址:http://www.cnblogs.com/ysjshrine/p/4346688.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!