【发布时间】:2014-01-28 14:02:07
【问题描述】:
我想在我的 main.cpp 程序中包含 printstuff.h。我得到没有这样的文件或目录错误。我不想把整个目录用双引号引起来。我只想简单地把 printstuff.h 我怎么做到这一点?
我正在使用 Visual Studio 2012。
main.cpp
#include<iostream>
#include<cstdlib>
#include<printstuff.h>
using namespace std;
inline void swap( int *x, int *y ) {
int *z = x;
*x = *y;
*y = *z;
}
int main( ) {
/*int x = 0, y = 1;
swap( x, y );
cout << x << endl << y << endl;*/
printStuff( );
system( "pause" );
return 0;
}
printstuff.h
#include<iostream>
using namespace std;
void printStuff( );
void printStuff( ) {
int count[ ] = { 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 };
char symb[ ] = "abcdefghijk";
for ( int j = 1; j < 12; j++ ) {
char c = symb[ j ];
for ( int i = 0; i < 11; i++ ) {
int times = count[ i ];
while ( times != 0 ) {
cout << c;
times--;
}
cout << endl;
}
}
}
【问题讨论】:
-
在你的项目设置中添加头文件的路径
-
#include "printstuff.h"
标签: c++ header active-directory include