注册 登录
编程论坛 C++教室

初学者,谢谢帮我看下错在哪里...

lvyan 发布于 2008-04-18 15:31, 666 次点击
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<iomanip.h>
using namespace std;
class stu
{
private:
    int num;
    char name[10];
    int age;
public:
    stu(int n,char a[10],int e)
    { num=n;
      strcpy(name,a);
      age=e;
    }
   
    void display()
    {  cout<<num<<setw(6);
       cout<<name<<setw(3);
       cout<<age<<endl;
       }

};


int main()
{  clrscr();
   stu stu1(10,"lvyan",19), stu2(11,"xufan",20);
   stu1.display();
   stu2.display();
   cin.get();
   return 0;
}


--------------------Configuration: 123 - Win32 Debug--------------------
Compiling...
1.cpp
e:\vc\vc6cn\myprojects\123\1.cpp(36) : fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.

123.exe - 1 error(s), 0 warning(s)
5 回复
#2
lvyan2008-04-18 15:35
我觉得代码没问题,好象是运行错误...
   就是不知道什么意思?
#3
sunkaidong2008-04-18 16:04
#include<iostream>
#include<conio.h>
#include<string>
#include<iomanip>
using namespace std;
class stu
{
private:
    int num;
    char name[10];
    int age;
public:
    stu(int n,char a[10],int e)
    { num=n;
      strcpy(name,a);
      age=e;
    }
   
    void display()
    {  cout<<num<<setw(6);
       cout<<name<<setw(3);
       cout<<age<<endl;
       }

};
#4
lvyan2008-04-18 16:05
联编之后,得到的文件没有.exe后缀.
  请高手指教..  我刚开始用VC. 不知道什么原因..
#5
pklong0072008-04-18 16:59
如此情况是编译器的问题了,不过代码本身也有问题,应该把头文件改成二楼的方式,不过clrscr();在C++中不能用,应该用system("cls")清屏
#6
aspvbc2008-04-18 17:33
http://pickup.
教程
1