vs2010我建立了一个cpp文件,怎么c与c++可以共同使用?见下列代码。c那与c+有什么区别?

#include <stdio.h>//从输入的一个数字倒数到0
#include <iostream>
#define STOP 0
int main()
{
int counter;
int startPoint;
printf("=====Countdown Program=====");
std::cout<<std::endl;
printf("Enter a positive integer: ");
scanf("%d",&startPoint);
for(counter=startPoint;counter>=STOP;counter--)
printf("%d\n",counter);
system("pause");
}

C++兼容C语言,所以可以一起用,
nclude <stdio.h>//C语言的头文件
#include <iostream>//C++的头文件
cout,cin的是C++的
scanf,printf是C的
其他的没什么区别
system也是C++的
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-10-04
c++可以说是对c的继承和发展 一般c++的编译器都能编译c
但两者差别还是挺大的
首先是编程思想(面向过程还是对象)
语法也是 例如c s是用printf() c++则是用cout等来进行输出
相似回答
大家正在搜