你的程序错误,是在
cout << “Enter the temperature in Celsius:”;
cout << “Fahrenheit value is:”;中用了中文状态下的双引号。
#include
#include
#include
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// enter the temperature in Celsius
int celsius;
cout << "Enter the temperature in Celsius:";
cin >> celsius;
// calculate conversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 - 32;
// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;
// output the results (followed by a NewLine)
cout << "Fahrenheit value is:";
cout << fahrenheit << endl;
// wait until user is ready before terminating program
// to allow the user to see the program results
system("PAUSE");
return 0;
}
以上程序正确,可以运行。
如果还不行,那就是编译器的问题。建议:用vc2008,c-free或vc2010.微软已停止对vc6.0进行更新了。(开始不习惯很正常,成为高手后会喜欢例如vc2010的)。
#include
#include
int main()
{
int gg(int i);
int i;
while(1){
i=0;
printf(" 1.查看历史日程表\n");
printf(" 2.输入新的日程表\n");
printf(" 3.查看已完成的日程表\n");
printf(" 4.查看未完成的日程表\n");
printf(" 5.退出登录\n");
printf(" 请选择相应序号: ");
scanf("%d",&i);
if(i==5){
break;
}
gg(i);
printf("\n");
printf("\n");
printf("\n");
}
}
int gg(int i){
int aa();
int bb();
int cc();
int dd();
switch(i){
case 1:
aa();break;
case 2:
bb();break;
case 3:
cc();break;
case 4:
dd();break;
}
}
int aa(){
FILE*fp;
int length=1000;
char str[1001];
if((fp=fopen("11s.txt","r"))==NULL){
printf("无文件");
return 0;
}
while(fgets(str,length,fp)!=NULL){
printf("%s",str);}
return 1;
fclose(fp);
}
int bb(){
FILE*fp;
char str[400];
printf("内容如下:\n");
scanf("%s",str);
if((fp=fopen("11s.txt","a+"))==NULL){
printf("文件不存在");
return 0;
}
fputs("\n",fp);
fputs(str,fp);
printf("加入成功");
fclose(fp);
return 1;
}
int cc(){
FILE*fp;
int length=1000;
char str[1001];
printf("内容如下:\n");
if((fp=fopen("11s.txt","r"))==NULL){
printf("无文件");
return 0;
}
while(fgets(str,length,fp)!=NULL){
if(strstr(str,"已完成")!=NULL){
printf("%s",str);
}
}
fclose(fp);
return 1;
}
int dd(){
FILE*fp;
int lenght=1000;
char str[1001];
printf("内容如下:\n");
if((fp=fopen("11s.txt","r"))==NULL){
printf("无文件");
return 0;
}
while(fgets(str,lenght,fp)!=NULL){
if(strstr(str,"未完成")!=NULL){
printf("%s",str);
}
}
fclose(fp);
return 1;
}