C/C++之Exercise

一.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 // 工程子目录

时间: 2025-01-15 13:32:00

C/C++之Exercise的相关文章

Exercise: Maps (单词统计)

A Tour of Go Exercise: Maps https://tour.golang.org/moretypes/23 WordCount (单词统计) 是一个很经典的小程序了,在很多编程入门教程中都会出现. 这道题比较简单,但也有一些知识点值得一提. 上面这个答案我是参考了网上别人写的.但在参考别人之前我也自己解题了,其中,唯一不同之处是这一句: m[word]++ 我本来写的是: _, ok := m[word] if ok { m[word]++ } else { m[word]

Exercise: Slices (画图)

A Tour of Go Exercise: Slices https://tour.golang.org/moretypes/18 这道题目,提供了一个画图函数 (pic.Show), 可以生成图片. 这个函数,即 pic.Show(f func(int, int) [][]uint8), 可见,它接受一个函数做参数,题目要求的正是编写这个参数.答案如下: 这里面,依赖一个 package, 即 "golang.org/x/tour/pic" 我上 https://github.co

Stanford coursera Andrew Ng 机器学习课程编程作业(Exercise 2)及总结

Exercise 1:Linear Regression---实现一个线性回归 关于如何实现一个线性回归,请参考:http://www.cnblogs.com/hapjin/p/6079012.html Exercise 2:Logistic Regression---实现一个逻辑回归 问题描述:用逻辑回归根据学生的考试成绩来判断该学生是否可以入学. 这里的训练数据(training instance)是学生的两次考试成绩,以及TA是否能够入学的决定(y=0表示成绩不合格,不予录取:y=1表示录

【DeepLearning】Exercise:PCA in 2D

Exercise:PCA in 2D 习题的链接:Exercise:PCA in 2D pca_2d.m close all %%================================================================ %% Step 0: Load data % We have provided the code to load data from pcaData.txt into x. % x is a 2 * 45 matrix, where the

kk Exercise 6.1 Convert an integer to words

Exercise 6-1. write a program that will prompt for and read a positive integer less than1,000 from the keyboard, and then create and output a string that is the value of theinteger in words. For example, if 941 is entered, the program will create the

Exercise 3.3 Calculate a discounted price

Exercise 3-3. Write a program that will calculate the price for a quantity entered from the keyboard, given that the unit price is $5 and there is a discount of 10 percent for quantities over 30 and a 15 percent discount for quantities over 50. 1 //

[Usaco2010 Dec]Exercise 奶牛健美操

[Usaco2010 Dec]Exercise 奶牛健美操 题目 Farmer John为了保持奶牛们的健康,让可怜的奶牛们不停在牧场之间 的小路上奔跑.这些奶牛的路径集合可以被表示成一个点集和一些连接 两个顶点的双向路,使得每对点之间恰好有一条简单路径.简单的说来, 这些点的布局就是一棵树,且每条边等长,都为1. 对于给定的一个奶牛路径集合,精明的奶牛们会计算出任意点对路径的最大值, 我们称之为这个路径集合的直径.如果直径太大,奶牛们就会拒绝锻炼. Farmer John把每个点标记为1..V

Exercise 2.3 Calculating volume price of alternative products

// Exercise 2.3 Calculating volume price of alternative products // The only problem here is to devise a way to determine the price // for the product type. Here I used the product type value to do this. #include <stdio.h> int main(void) { double to

Exercise 2.1 Convert inches to yards, feet, and inches

Exercise 2-1. Write a program that prompts the user to enter a distance in inches andthen outputs that distance in yards, feet, and inches. (For those unfamiliar with imperialunits, there are 12 inches in a foot and 3 feet in a yard.) #include <stdio

List exercise

The slice operator can take a third argument that determines the step size, so t[::2] creates a list that contains every other element from t. If the step size is negative, it goes through the list backward, so t[::-1] creates a list of all the eleme