如何解决fatal error C1004: unexpected end of file found        
 error C2146: syntax error : missing ';' before identifier 'WndProc'
不知是何因?应该是结构问题,却检查没有错误。
具体代码如下:include <windows.h>
//头文件
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); //窗口函数声明
char szClassName[]="windowclass"; //窗口结构体的名称
char szAppTitle[]="API建立窗口实例"; //窗口的标题
INT PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, INT nCmdShow)//WinMain()函数的定义
{
HWND hMainWnd; //窗口句柄
MSG msg; //消息结构体
WNDCLASS winclass; //窗口结构体
  if(!hPrevInstance) //判断是否已有应用程序的实例在运行,给窗口结构体的数据成员赋值来规定所有建立的窗口的特征
  {
 winclass.style=CS_HREDRAW|CS_VREDRAW; //窗口风格
 winclass.lpfnWndProc=WndProc; //窗口的消息处理函数
 winclass.cbClsExtra=0; //窗口类无扩展
 winclass.cbWndExtra=0; //窗口实例无扩展
 winclass.hInstance=hInstance; //当前应用程序实例句柄
 winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); //窗口的最小化图标为缺省图标
 winclass.hCursor=LoadCursor(NULL,IDC_ARROW); //窗口采用箭头光标
 winclass.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
//窗口背景色为浅灰
 winclass.lpszMenuName=NULL; // 无窗口菜单
 winclass.lpszClassName=szClassName; // 给窗口结构体命名
 RegisterClass(&winclass); //注册窗口
  }
                                                        //下面用CreateWindow()函数建立窗口,并返回所建立窗口的句柄
  hMainWnd=CreateWindow(
 szClassName, //窗口结构体的名称
 szAppTitle, //窗口的标题
 WS_OVERLAPPEDWINDOW, //窗口风格为可重叠窗口  CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
//4个参数代表窗口左上角x,y坐标和窗口的宽度与高度,都是用缺省值
 NULL,NULL,hInstance,NULL);
ShowWindow(hMainWnd,SW_SHOWNORMAL); //显示窗口
UpdateWindow(hMainWnd); //更新窗口
//下面用while()循环来建立消息循环
while(GetMessage(&msg,NULL,0,0)) //获取消息,填充msg结构体
{
TranslateMessage(&msg); //翻译键盘销息
DispatchMessage(&msg); //向窗口函数发送消息,让窗口函数处理
}
return msg.wParam;
}
LRESULT CALLBACE WndProc(HWND hMainwnd, UINT message, WPARAM wParam, LPARAM lParam) //窗口函数的定义
{
HDC hdc; //设备描述表
PAINTSTRUCT ps; //矩形结构
char messageleft[]="按下了鼠标左键!"; //单击鼠标左键,消息框将显示的提示内容
char messageright[]="按下了鼠标右键!"; //单击鼠标右键,消息框将显示的提示内容

swatch(message)
{
case WM_PAINT; //窗口重绘
{
hdc=BeginPaint(hMainwnd,&ps);
GetClientRect(hMainwnd,&rect);
DrawText(hdc,TEXT("使用API建立windows窗口实例!"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_Visual C++ENTER);
//在客户区中英输出文字
EndPaint(hMainwnd,&ps);
break;
}
case WN_RBUTTONDOWN:
{
MessageBox(GetFocus(),messageright,"API建立窗口实例",MB_OK|MB_ICONINFORMATION);
break;
}
case WM_LBUTTONDOWN:
{
MessageBox(GetFocus(),messageleft,"API建立窗口实例",MB_OK|MB_ICONINFORMATION);
break;
}
case WN_DESTROY: //关闭应用程序窗口时发出的消息
{
PostQuitMessage(0); //发出WM_QUIT消息,结束应用程序
return 0;
}
default:
break;
}
return DefWindowProc(hMainwnd,message,wParam,lParam); //其他消息交给windows作默认处理
}
感谢解答。

解决方案 »

  1.   

    LRESULT CALLBACE WndProc
      

  2.   

    这是我的程序。给出了编译结果。还请大家看看那里错啦!!!#include <stdio.h>
    #include <stdlib.h>
    #include <malloc.h>
    #include <string.h>
    #define OK   1
    #define ERROR  0
    #define MAXSIZE  100   /*此处的宏定义常量表示线性表可能达到的最大长度*/
    typedef struct TV
    { char type[20];
       int count;
       float price;
    }ElemType;
    typedef  struct

    ElemType  elem[MAXSIZE];  /*线性表占用的数组空间*/
        int       last;    /*记录线性表中最后一个元素在数组elem[ ]中的位置(下标值),空表置为-1*/
    }SeqList;
    ElemType Locate(SeqList L,char Type[20])
    {
    ElemType p;
    int i;
    for(i=0;i<=L.last;i++)
    if(strcmp(L.elem[i].type,Type)==0)
    {
    strcpy(p.type,L.elem[i].type);
    p.count=L.elem[i].count;
    p.price=L.elem[i].price;
    return(p);
    }
    }
    ElemType * InsList(SeqList L,ElemType e)
    {
    ElemType * q;
    int i;
    for(i=0;i<=L.last;i++)
    if(strcmp(L.elem[i].type,e.type)==0)
    {
    strcpy(q->type,L.elem[i].type);
    q->count=L.elem[i].count+e.count;
    q->price=L.elem[i].price;
    return(q);
    }
    else
    {
    strcpy(L.elem[L.last+1].type,e.type);
    L.elem[L.last+1].count=e.count;
    L.elem[L.last+1].price=e.price;
    L.last++;
    }
    }
    ElemType OutList(SeqList L,ElemType e)
    {
    ElemType b;
    int i;
    for(i=0;i<=L.last;i++)
    if(strcmp(L.elem[i].type,e.type)==0)
    {
    strcpy(b.type,L.elem[i].type);
    b.count=L.elem[i].count-e.count;
    b.price=L.elem[i].price;
    return(b);
    }
    }
    ElemType * DelList(SeqList L,char Type[20])
    {
    ElemType * y;
    int i,k;
    for(i=0;i<=L.last;i++)
    if(strcmp(L.elem[i].type,Type)==0)
    {
    strcpy(y->type,L.elem[i].type);
    y->count=L.elem[i].count;
    y->price=L.elem[i].price;
    return(y);
    for(k=i;i<=L.last;k++)
    {     strcpy(L.elem[k-1].type,L.elem[k].type);
        L.elem[k-1].count=L.elem[k].count;
        L.elem[k-1].price=L.elem[k].price;
        L.last--;
    } }
    }
    void GetIn(SeqList L,int i,int MAXSIZE)
    {
    InitList(SeqList L);
    &L=(SeqList *)malloc(sizeof(SeqList));
    for(i=0;i<=MAXZIAE;i++)
    scanf("%s,%d,%f",L.elem[i].type,&L.elem[i].count,&L.elem[i].price);
    }
    void InitList(SeqList L)
    void main()
    {
    ElemType m,e,a;
    ElemType *n,*x;
    char Type[20];
    int i,c;
    SeqList L;
    printf("     **********   TV   **********     \n");
    printf("                                      \n");
    printf("         First  EnterIn  !\n");
    printf("         Second Locate  !\n");
    printf("         Third  InsList  !\n");
    printf("         Fouth  OutList  !\n");
    printf("         Fifth  DelList  !\n");
    printf("     ****************************     \n");
    printf("please Make a choice !\n");
    scanf("%d",&c);
    switch(c)
    case 1:
    printf("请输入库中所有电视机的信息:\n");
    GetIn(SeqList L,int i,int MAXSIZE);
    break; case 2:
    {
    printf("请输入想要查询的电视机型号:\n");
    scanf("%s",Type);
    if(m=Locate(SeqList L,char Type[20]))
    {
    printf("%s,%d,%f",m.type,m.count,m.price);
    }
    printf("库存中不存在该型号的电视机!\n");
            }
    break;
    case 3:
    printf("请输入要入库的电视机信息:\n");
    scanf("%s,%d,%f",e.type,&e.count,&e.price);
    if(n==InsList(SeqList L,ElemType e))
    {
    printf("库存已存在该型号的电视机!入库后的信息为:\n");
    printf("%s,%d,%f",n->type,n->count,n->price);
    }

    printf("库存不存在该型号的电视机!入库后的信息为:\n");
        printf("%s,%d,%f",e.type,e.count,e.price);
    break; case 4:
    printf("请输入要出库的电视机信息:\n");
    scanf("%s,%d,%f",e.type,&e.count,&e.price);
    if(a==OutList(SeqList L,ElemType e))
    {
    printf("库存已存在该型号的电视机!出库后的信息为:\n");
    printf("%s,%d,%f",a.type,a.count,a.price);
    }
    printf("库存中不存在该型号的电视机!无法出库!\n");
            break;
    case 5:
    printf("请输入想要删除的电视机型号:\n");
    scanf("%s",Type);
    if(x==DelList(&L,char Type[20]))
    {
    printf("删除成功!所删电视机的信息为:\n");
        printf("%s,%d,%f",x->type,x->count,x->price);
    }
    printf("删除失败!库中不存在该型号的电视机!\n");
    break;

    }这是本人的程序的。编译结果如下
    -------------------Configuration: TV-顺序结构 - Win32 Debug--------------------
    Compiling...
    TV-顺序结构.CPP
    C:\Documents and Settings\Administrator\My Documents\文档处理区\TV-顺序结构.CPP(86) : error C2143: syntax error : missing ')' before 'constant'
    C:\Documents and Settings\Administrator\My Documents\文档处理区\TV-顺序结构.CPP(86) : error C2143: syntax error : missing ';' before 'constant'
    C:\Documents and Settings\Administrator\My Documents\文档处理区\TV-顺序结构.CPP(86) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.TV-顺序结构.OBJ - 3 error(s), 0 warning(s)