搭建eclipse下的c和c++开发环境
我们需要一个cdt,这个可以在Eclipse官网下载。
我们需要MinGW——C/C++编译平台,下载后需要安装,同时选中g++、MinGW Make,同时设置环境变量,将%MinGW_HOME%\bin设置到PATH中,然后我们可以通过命令行敲击gcc,看是否有效果。
我们需要gdb——C/C++调试平台,下载后安装,默认到MinGW_HOME就行。
我们开启eclipse编译一个C/C++工程,右键可以运行,调试。
一直都想在Eclipse下搭建一个C/C++的开发平台,却一直未能如愿。最近,终于成功了,其实很简单。
安装
设置环境变量
新建C项目
新建C++项目
来段HelloWorld
C的
C代码
#include ﹤stdio.h>
#include ﹤stdlib.h>
int main(void) {
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
return EXIT_SUCCESS;
}
控制台编译输出
Console代码
**** Build of configuration Debug for project c ****
**** Internal Builder is used for build ****
gcc -O0 -g3 -Wall -c -fmessage-length=0 -osrc\c.o ..\src\c.c
gcc -oc.exe src\c.o
Build complete for project c
Time consumed: 14011 ms.
控制台结果输出
Console代码
!!!Hello World!!!
C++的
C++代码
#include ﹤iostream>
using namespace std;
int main() {
cout ﹤﹤ "!!!Hello World!!!" ﹤﹤ endl; // prints !!!Hello World!!!
return 0;
}
控制台编译输出
Console代码
**** Build of configuration Debug for project cpp ****
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\cpp.o ..\src\cpp.cpp
g++ -ocpp.exe src\cpp.o
Build complete for project cpp
Time consumed: 25452 ms.
控制台结果输出
Console代码
!!!Hello World!!!
相关文档:
掌握文本文件读写的方法
了解二进制文件的读写方法
C++文件流:
fstream // 文件流
ifstream // 输入文件流
ofstream // 输出文件流
//创建一个文本文件并写入信息
//同向屏幕上输出信息一样将信息输出至文件
#include<iomanip.h>
#include<fstream.h>
void main()
{
ofstream f1("d:\\ ......
VC++
与VB
数据类型对应关系
在做VC与vb程序间互相调用,需要注意两种语言不同编译器对数据类型的定义区别,此时两者数据类型的对应关系就显得十分的重要,对应关系以及声明方式如下所示。
VC++
VB
short
Integer
int
Long
long
Long
UNIT
Long
ULONG
Long
WORD
DWORDLon ......
http://msdn.microsoft.com/en-us/library/2e70t5y1(VS.80).aspx
#pragma
pack( n )
n : Valid values are 1, 2, 4, 8, and 16.the
alignment of a member will be on a boundary that is either a multiple of
n
or
a multiple of the size of the member
,
whichever is smaller.
......