| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2425 人关注过本帖
标题:小区水电管理系统,有很多错误,求指点
只看楼主 加入收藏
zzqm
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2017-5-6
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:7 
小区水电管理系统,有很多错误,求指点
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100
#define w 1.5
#define e 0.5
typedef struct  sdf
{
  int number;        //住户门牌号
  char name;        //住户姓名
double  sa,da;   //用水(吨),用电(度)
double  sf,df;    //水费,电费
char  time;       //收费时间
} SDF;
void AdddataFunc();
void StatisdataFunc();
void SortdataFunc();
void DeletedataFunc();
void QuerydataFunc();
void ModifdataFunc();
void CaldataFunc();
void SavedataFunc();
int main()
{
 int select;
 scanf("%d",&select);
 switch(select)
 {
case 1:
  AdddataFunc(); break;       //添加
case 2:
 StatisdataFunc(); break;      //统计
case 3:
  SortdataFunc(); break;      //排序
case 4:
  DeletedataFunc();break;       //删除
case 5:
  QuerydataFunc(); break;     //查询
case 6:
  ModifdataFunc(); break;     //修改
case 7:
  Exit(0);                    //退出
 }
}
void display(void)
{
  system("cls");       //清屏
  printf("欢迎使用住户水电费管理系统\n");
  printf("在本系统中欲执行某功能请按相应数字\n");
  printf("1 添加\n");
  printf("2 统计\n");
  printf("3 排序\n");
  printf("4 删除\n");
  printf("5 查询\n");
  printf("6 修改\n");
  printf("7 退出\n");
}

void SavedataFunc()
{
  FILE *fp;
 fp=fopen("Data.txt","w") ;
 int i,j;
 for(i=0;i<N;i++)
{
 fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
 for(j=0;j<100;j++)
 {
 fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
 }
}
fclose(fp);
}
void AdddataFunc()
{
 
 int i,j;
 SD sd;
 printf("请输入新用户信息");
 system ("cls");
 for(i=0;i<N;i++)
 {
     printf("\n\t\tnumber:");
     scanf("%d",sd.number);
     (p+i)-number=sd.number;
     printf("\n\t\tname");
     scanf("%d",sd.name);
     stcpy((p+i)-name,sd.name);
     for(i=0;j<100;j++)
     {
         printf("\n\t\tsa:");
         scanf("%d",sd.sa[j]);
         (p+i)-sa=sd.sa;
         printf("\n\t\tsa:");
         scanf("%d",sd.da[j]);
         (p+i)-da=sd.da;
         printf("\n\t\ttime");
         scanf("%d",sd.time);
         stcpy((p+i)-time,sd.time);
     }
     printf("\n登记完毕!\n"); break;
 }
 SavedataFunc();
}
void SortdataFunc()
{
    int i,j;
    SD t;
    for(i=0;i<N-1;i++)
    {
    for(j=0;j<N;j++)
     {
        if((p+i)-number<(p+j)-number)
        {
            t=(p+i);
            (p+i)=(p+j);
            (p+j)=t;
        }
     }   
    }
    SavadataFunc();
}
void QuerydataFunc()
{
    int i,j,n;
    SD sd;
    system("cls");
    puts("\t\t\t 查询\n");
    puts("\t\t\t* *\n");
    puts("\t\t\t 1.住户门牌号\n");
    puts("\t\t\t 2.户主姓名\n");
    puts("\t\t\t 3.日期\n");
    puts("\t\t\t\n");
    printf("你想通过第几种方式查询?\b\b") ;
    scanf("%d",&n);
    switch(n)
    {
        case 1:
            {
                printf("住户门牌号:");
                scanf("%",sd.number);
                for(i=0;i<N;i++)
                {
                    if((p+i)-number=sd.number)break;
                    printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                    for(j=0;j<100;j++)
                    {
                        printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                    }
                }
            }break;
        case 2:
            {
                printf("姓名:");
                scanf("%s",sd.name);
                for(i=0;i<N;i++)
                {
                    if(strcmp((p+i)-name=sd.name)==0)break;
                    printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                    for(j=0;j<100;j++)
                    {
                        printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                    }
                }
            }break;
        case 3:
            {
                printf("日期:");
                scanf("%s".sd.time);
                        for(i=0;i<N;i++)
                {
                    if(strcmp((p+i)-name=sd.name)==0)break;
                    printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                    for(j=0;j<100;j++)
                    {
                        printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                    }
                }
            }break;
            
            
    }
}
void DeleteFunc()
{
    int i,j,m;
    printf("删除住户门牌号:[]\b\b");
    scanf("%d",&m);
    for(i=0;i<N;i++)
    {
        if((p+i)-number==0)
        {
            strcpy((p+i)-name,(p+j+1)-name);
            (p+i)-sf=(p+i+1)-sf;
        }
    }
            for(j=0;j<100;j++)
            {
              (p+i)-sd[j]=(p+i+1)-sd[j+1];
              (p+i)-df=(p+i+1)-df[j+1];
              strcpy((p+i)-time[j],(p+i+1)-time[j+1]);
            }
        
    SavadataFunc();
}

编译单个文件...
--------
- 文件名: C:\Users\zqm\Documents\未命名1.cpp
- 编译器名: TDM-GCC 4.9.2 64-bit Release

处理 C++ 源文件...
--------
- C++ 编译器: E:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe
- 命令: g++.exe "C:\Users\zqm\Documents\未命名1.cpp" -o "C:\Users\zqm\Documents\未命名1.exe"  -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++" -L"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"E:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc
C:\Users\zqm\Documents\未命名1.cpp:140:5: error: stray '\243' in program
     printf("住户门牌号:");
     ^

C:\Users\zqm\Documents\未命名1.cpp:140:5: error: stray '\273' in program

C:\Users\zqm\Documents\未命名1.cpp: In function 'int main()':
C:\Users\zqm\Documents\未命名1.cpp:42:9: error: 'Exit' was not declared in this scope
   Exit(0);                    //退出
         ^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void SavedataFunc()':
C:\Users\zqm\Documents\未命名1.cpp:66:24: error: 'p' was not declared in this scope
  fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
                        ^
C:\Users\zqm\Documents\未命名1.cpp:66:29: error: 'number' was not declared in this scope
  fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
                             ^
C:\Users\zqm\Documents\未命名1.cpp:66:42: error: 'name' was not declared in this scope
  fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
                                          ^
C:\Users\zqm\Documents\未命名1.cpp:66:53: error: 'sf' was not declared in this scope
  fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
                                                     ^
C:\Users\zqm\Documents\未命名1.cpp:69:27: error: 'sa' was not declared in this scope
  fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
                           ^
C:\Users\zqm\Documents\未命名1.cpp:69:36: error: 'sd' was not declared in this scope
  fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
                                    ^
C:\Users\zqm\Documents\未命名1.cpp:69:45: error: 'df' was not declared in this scope
  fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
                                             ^
C:\Users\zqm\Documents\未命名1.cpp:69:54: error: 'time' was not declared in this scope
  fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
                                                      ^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void AdddataFunc()':
C:\Users\zqm\Documents\未命名1.cpp:78:2: error: 'SD' was not declared in this scope
  SD sd;
  ^
C:\Users\zqm\Documents\未命名1.cpp:84:14: error: 'sd' was not declared in this scope
   scanf("%d",sd.number);
              ^
C:\Users\zqm\Documents\未命名1.cpp:85:4: error: 'p' was not declared in this scope
   (p+i)-number=sd.number;
    ^
C:\Users\zqm\Documents\未命名1.cpp:85:9: error: 'number' was not declared in this scope
   (p+i)-number=sd.number;
         ^
C:\Users\zqm\Documents\未命名1.cpp:88:15: error: 'name' was not declared in this scope
   stcpy((p+i)-name,sd.name);
               ^
C:\Users\zqm\Documents\未命名1.cpp:88:27: error: 'stcpy' was not declared in this scope
   stcpy((p+i)-name,sd.name);
                           ^
C:\Users\zqm\Documents\未命名1.cpp:93:10: error: 'sa' was not declared in this scope
    (p+i)-sa=sd.sa;
          ^
C:\Users\zqm\Documents\未命名1.cpp:96:10: error: 'da' was not declared in this scope
    (p+i)-da=sd.da;
          ^
C:\Users\zqm\Documents\未命名1.cpp:99:19: error: 'time' was not declared in this scope
       stcpy((p+i)-time,sd.time);
                   ^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void SortdataFunc()':
C:\Users\zqm\Documents\未命名1.cpp:108:2: error: 'SD' was not declared in this scope
  SD t;
  ^
C:\Users\zqm\Documents\未命名1.cpp:113:7: error: 'p' was not declared in this scope
   if((p+i)-number<(p+j)-number)
       ^
C:\Users\zqm\Documents\未命名1.cpp:113:12: error: 'number' was not declared in this scope
   if((p+i)-number<(p+j)-number)
            ^
C:\Users\zqm\Documents\未命名1.cpp:115:4: error: 't' was not declared in this scope
    t=(p+i);
    ^
C:\Users\zqm\Documents\未命名1.cpp:121:15: error: 'SavadataFunc' was not declared in this scope
  SavadataFunc();
               ^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void QuerydataFunc()':
C:\Users\zqm\Documents\未命名1.cpp:126:2: error: 'SD' was not declared in this scope
  SD sd;
  ^
C:\Users\zqm\Documents\未命名1.cpp:141:5: error: expected ';' before 'scanf'
     scanf("%",sd.number);
     ^
C:\Users\zqm\Documents\未命名1.cpp:144:10: error: 'p' was not declared in this scope
      if((p+i)-number=sd.number)break;
          ^

C:\Users\zqm\Documents\未命名1.cpp:144:15: error: 'number' was not declared in this scope
      if((p+i)-number=sd.number)break;
               ^
C:\Users\zqm\Documents\未命名1.cpp:144:22: error: 'sd' was not declared in this scope
      if((p+i)-number=sd.number)break;
                      ^
C:\Users\zqm\Documents\未命名1.cpp:145:61: error: 'p' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                             ^
C:\Users\zqm\Documents\未命名1.cpp:145:64: error: expression cannot be used as a function
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                ^
C:\Users\zqm\Documents\未命名1.cpp:145:66: error: 'nnumber' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                  ^
C:\Users\zqm\Documents\未命名1.cpp:145:80: error: 'name' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                                ^
C:\Users\zqm\Documents\未命名1.cpp:145:91: error: 'sf' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                                           ^
C:\Users\zqm\Documents\未命名1.cpp:148:66: error: 'sa' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                  ^
C:\Users\zqm\Documents\未命名1.cpp:148:78: error: 'da' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                              ^
C:\Users\zqm\Documents\未命名1.cpp:148:90: error: 'df' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                                          ^
C:\Users\zqm\Documents\未命名1.cpp:155:16: error: 'sd' was not declared in this scope
     scanf("%s",sd.name);
                ^
C:\Users\zqm\Documents\未命名1.cpp:158:17: error: 'p' was not declared in this scope
      if(strcmp((p+i)-name=sd.name)==0)break;
                 ^
C:\Users\zqm\Documents\未命名1.cpp:158:22: error: 'name' was not declared in this scope
      if(strcmp((p+i)-name=sd.name)==0)break;
                      ^
C:\Users\zqm\Documents\未命名1.cpp:159:61: error: 'p' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                             ^
C:\Users\zqm\Documents\未命名1.cpp:159:64: error: expression cannot be used as a function
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                ^
C:\Users\zqm\Documents\未命名1.cpp:159:66: error: 'nnumber' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                  ^
C:\Users\zqm\Documents\未命名1.cpp:159:80: error: 'name' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                                ^
C:\Users\zqm\Documents\未命名1.cpp:159:91: error: 'sf' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                                           ^

C:\Users\zqm\Documents\未命名1.cpp:162:66: error: 'sa' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                  ^
C:\Users\zqm\Documents\未命名1.cpp:162:78: error: 'da' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                              ^
C:\Users\zqm\Documents\未命名1.cpp:162:90: error: 'df' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                                          ^
C:\Users\zqm\Documents\未命名1.cpp:169:16: error: request for member 'sd' in '"%s"', which is of non-class type 'const char [3]'
     scanf("%s".sd.time);
                ^
C:\Users\zqm\Documents\未命名1.cpp:172:17: error: 'p' was not declared in this scope
      if(strcmp((p+i)-name=sd.name)==0)break;
                 ^
C:\Users\zqm\Documents\未命名1.cpp:172:22: error: 'name' was not declared in this scope
      if(strcmp((p+i)-name=sd.name)==0)break;
                      ^
C:\Users\zqm\Documents\未命名1.cpp:172:27: error: 'sd' was not declared in this scope
      if(strcmp((p+i)-name=sd.name)==0)break;
                           ^
C:\Users\zqm\Documents\未命名1.cpp:173:61: error: 'p' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                             ^
C:\Users\zqm\Documents\未命名1.cpp:173:64: error: expression cannot be used as a function
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                ^
C:\Users\zqm\Documents\未命名1.cpp:173:66: error: 'nnumber' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                  ^
C:\Users\zqm\Documents\未命名1.cpp:173:80: error: 'name' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                                ^
C:\Users\zqm\Documents\未命名1.cpp:173:91: error: 'sf' was not declared in this scope
      printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
                                                                                           ^
C:\Users\zqm\Documents\未命名1.cpp:176:66: error: 'sa' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                  ^
C:\Users\zqm\Documents\未命名1.cpp:176:78: error: 'da' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                              ^
C:\Users\zqm\Documents\未命名1.cpp:176:90: error: 'df' was not declared in this scope
       printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
                                                                                          ^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void DeleteFunc()':
C:\Users\zqm\Documents\未命名1.cpp:191:7: error: 'p' was not declared in this scope
   if((p+i)-number==0)
       ^
C:\Users\zqm\Documents\未命名1.cpp:191:12: error: 'number' was not declared in this scope
   if((p+i)-number==0)
            ^
C:\Users\zqm\Documents\未命名1.cpp:193:17: error: 'name' was not declared in this scope
    strcpy((p+i)-name,(p+j+1)-name);
                 ^
C:\Users\zqm\Documents\未命名1.cpp:194:10: error: 'sf' was not declared in this scope
    (p+i)-sf=(p+i+1)-sf;
          ^

C:\Users\zqm\Documents\未命名1.cpp:199:7: error: 'p' was not declared in this scope
      (p+i)-sd[j]=(p+i+1)-sd[j+1];
       ^
C:\Users\zqm\Documents\未命名1.cpp:199:12: error: 'sd' was not declared in this scope
      (p+i)-sd[j]=(p+i+1)-sd[j+1];
            ^
C:\Users\zqm\Documents\未命名1.cpp:200:12: error: 'df' was not declared in this scope
      (p+i)-df=(p+i+1)-df[j+1];
            ^
C:\Users\zqm\Documents\未命名1.cpp:201:19: error: 'time' was not declared in this scope
      strcpy((p+i)-time[j],(p+i+1)-time[j+1]);
                   ^
C:\Users\zqm\Documents\未命名1.cpp:204:18: error: 'SavadataFunc' was not declared in this scope
     SavadataFunc();
                  ^


编译结果...
--------
- 错误: 70
- 警告: 0
- 编译时间: 2.22s

搜索更多相关主题的帖子: 管理系统 include double number 门牌号 
2017-05-06 19:46
renkejun1942
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:不是这样
等 级:贵宾
威 望:33
帖 子:1645
专家分:5297
注 册:2016-12-1
收藏
得分:4 
粗略扫了一眼,发现结构的运算符错误。

用指针访问结构成员的运算符是 ->
结构变量访问结构成员的运算符是 .

另外,你的程序是到是C还是C++?
如果是C++,那么你发错版面了,友情提示一下。
C的源代码文件后缀是 .c
C++的源代码文件后缀是 .cpp

[此贴子已经被作者于2017-5-6 19:53编辑过]


09:30 05/21 种下琵琶种子,能种活么?等待中……
21:50 05/27 没有发芽。
20:51 05/28 没有发芽。
23:03 05/29 没有发芽。
23:30 06/09 我有预感,要发芽了。
2017-05-06 19:52
zzqm
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2017-5-6
收藏
得分:0 
是c
2017-05-06 20:23
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:4 
多明显的错误提示啊
 error C2065: “p”: 未声明的标识符  连错误的行号都有的  

真不明白你们不看错误信息还是看不懂

DO IT YOURSELF !
2017-05-07 06:59
书生牛犊
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:星夜征程
等 级:贵宾
威 望:10
帖 子:1101
专家分:5265
注 册:2015-10-27
收藏
得分:4 
以下是引用wp231957在2017-5-7 06:59:48的发言:

多明显的错误提示啊
 error C2065: “p”: 未声明的标识符  连错误的行号都有的  

真不明白你们不看错误信息还是看不懂
赞同!    学写代码的第一课是准备运行环境和Helloworld   ,然后在接触变量、循环递归等等一系列概念的时候老师就应该开始有意识地培养“读懂错误信息”的能力了。我是在网上Mooc学的编程,老师就有教怎么看。
然后自己在解决对应报错信息的过程中逐渐熟练。可以说大部分“错误信息”能发现的问题都只是语法上的疏忽。
另外,新手写程序应该一小段一小段地写,一个功能一个功能地调试运行测试。等都写完了才开始改 一方面很多思路都忘了,改起来略费劲;另一方面有些逻辑上的错误一旦需要该结构那代码就得大段大段地删掉,这是及不划算的。养成习惯,以后写几千几万行的代码才不会滚屏滚到你费

φ(゜▽゜*)♪
2017-05-07 14:15
renkejun1942
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:不是这样
等 级:贵宾
威 望:33
帖 子:1645
专家分:5297
注 册:2016-12-1
收藏
得分:0 
回复 5楼 书生牛犊
这并不奇怪,中国大学CS专业最可怕的地方恐怕还不是到现在还在用谭浩强的垃圾书,还在于根本不会教学生如何Debug,而大部分学生也挺奇葩的,竟然就跟着学校的学,自己也不去注意这些东西,对编译器的警告和错误提示视而不见,太可怕了。

另外,知识结构不完整。

我觉得所有的学校在面对新生的时候,都应该从计算机操作和常识开始,然后扩展在硬件常识。

我就遇到过一个挺逗的人,竟然不知道什么是CMD,甚至于怎么打开都不知道。

[此贴子已经被作者于2017-5-7 17:28编辑过]


09:30 05/21 种下琵琶种子,能种活么?等待中……
21:50 05/27 没有发芽。
20:51 05/28 没有发芽。
23:03 05/29 没有发芽。
23:30 06/09 我有预感,要发芽了。
2017-05-07 17:25
zzqm
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2017-5-6
收藏
得分:0 
新改的,还有几个错误
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100
#define w 1.5                    // 水1.5元/吨
#define e 0.5                    // 电0.5元/

typedef struct Residentinf
{
    int number;                  // 住户门牌号
    char name[20];               // 户主姓名
    float *wanum,*elnum;       // 用水(吨)、电(度)表示数
    float *amoney,*emoney;      // 总共的水电费用,每月的水电费用   
    char *time;                 // 收费时间
}Re[N];

int num;                         // 数据个数
Residentinf *p;                 // 指向结构体的指针

void display();
void ScandataFunc();
void CaldataFunc();
void SavedataFunc();
void AdddataFunc();
void SortdataFunc();
void QuerydataFunc();
void StatisdataFunc();
void ModifydataFunc();
void DeletedataFunc();


int main()
{
 int select;
 scanf("%d",&select);
 switch(select)
 {
 case 1:
  AdddataFunc(); break;       //添加
 case 2:
  StatisdataFunc(); break;      //统计
 case 3:
  SortdataFunc(); break;      //排序
 case 4:
  DeletedataFunc();break;       //删除
 case 5:
  QuerydataFunc(); break;     //查询
 case 6:
  ModifydataFunc(); break;     //修改
 case 7:
  exit(0);                    //退出
 }
}

void display()
{
  system("cls");       //清屏
  printf("欢迎使用住户水电费管理系统\n");
  printf("在本系统中欲执行某功能请按相应数字\n");
  printf("1 添加\n");
  printf("2 统计\n");
  printf("3 排序\n");
  printf("4 删除\n");
  printf("5 查询\n");
  printf("6 修改\n");
  printf("7 退出\n");
}


void ScandataFunc()
{
    int i,j;
    FILE *fp;
    fp=fopen("Data.txt","r");
    for(i=0;i<N;i++)
    {
        fscanf(fp,"%d%s%d",&(p+i)->number,(p+i)->name,&(p+i)->amoney);
        for(j=0;j<100;j++)
            fscanf(fp,"%d%d%d%s",&(p+i)->wanum,&(p+i)->elnum,&(p+i)->emoney,(p+i)->time);
    }
    fclose(fp);
}

void CaldataFunc()
{
    int i,j;
    FILE *fp;
    fp=fopen("Data.txt","w");
    for(i=0;i<N;i++)
        for(j=1;j<100;j++)
        {
            (p+i)->emoney[j]=((p+i)->wanum[j]-(p+i)->wanum[j-1])*w+((p+i)->elnum[j]-(p+i)->elnum[j-i])*e;
            (p+i)->amoney=0;
            (p+i)->amoney=(p+i)->emoney;
        }
    SavedataFunc();
}

void SavedataFunc()
{
    FILE*fp;
    fp=fopen("Data.txt","w");
    int i,j;
    for(i=0;i<N;i++)
    {
        fprintf(fp,"%d %s %d",(p+i)->number,(p+i)->name,(p+i)->amoney);
        for(j=0;j<100;j++)
            fprintf(fp,"%d %d %d %s",(p+i)->wanum,(p+i)->elnum,(p+i)->emoney,(p+i)->time);
    }
    fclose(fp);
}
   
void AdddataFunc()
{

    int n,i,j;
    re;
    printf("请输入新用户信息");
    system("cls");
    for(i=0;i<N;i++)
        {
            printf("\n\t\tnumber:");
            scanf("%d",re.number);
            (p+i)->number=re.number;
            printf("\n\t\tname:");
            scanf("%s",re.name);
            strcpy((p+i)->name,re.name);
            for(j=0;j<100;j++)
            {
                printf("\n\t\twanum:");
                scanf("%d",&re.wanum[j]);
                (p+i)->wanum=re.wanum;
                printf("\n\t\telnum:");
                scanf("%d",&re.elnum[j]);
                (p+i)->elnum=re.elnum;
                printf("\n\t\t\ttime:");
                scanf("%s",re.time[j]);
                strcpy((p+i)->time,re.time);
            }
             printf("\n登记完毕!\n");break;
        }
    SavedataFunc();
}

void SortdataFunc()
{
    int i,j;
    Re[N] *temp;
    for(i=0;i<N-1;i++)
    {
        for(j=0;j<N;j++)
        if((p+i)->number<(p+j)->number)
        {
            temp=p+i;
            p+i=p+j;
            p+j=temp;
        }
    }
    SavedataFunc();
}

void QuerydataFunc()
{
    int i,n,j;
     *re;
    system("cls");
    puts("\t\t\t***************查询***************\n");
    puts("\t\t\t*                                *\n");
    puts("\t\t\t*            1.住户门牌号        *\n");
    puts("\t\t\t*            2.户主姓名          *\n");
    puts("\t\t\t*            3.日期              *\n");
    puts("\t\t\t**********************************\n");
    printf("您想通过第[ ]种方式查询?\b\b");
    scanf("%d",&n);
    switch(n)
    {
    case 1:
        {
            printf("住户门牌号:");
            scanf("%d",re.number);
            for(i=0;i<N;i++)
                if((p+i)->number==re[i].number)break;
            printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d",(p+i)->number,(p+i)->name,(p+i)->amoney);
            for(j=0;j<100;j++)
                printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)->wanum[j],(p+i)->elnum[j],(p+i)->emoney[j]);
        }break;
    case 2:
        {
            printf("姓名:\n");
            scanf("%s",re.name);
            for(i=0;i<N;i++)
                if(strcmp((p+i)->name,re[i].name)==0)break;
            printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d",(p+i)->number,(p+i)->name,(p+i)->amoney);
            for(j=0;j<100;j++)
                printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%f",(p+i)->wanum[j],(p+i)->elnum[j],(p+i)->emoney[j]);
        }break;
    case 4:
        {
            printf("日期:\n");
            scanf("%s",re.time);
            for(i=0;i<N;i++)
                for(j=0;j<100;j++)
                if(strcpy((p+i)->time[j],re.time[j])==0)break;
            printf("\n\t住户门牌号:%d\n\t户主姓名:%s",(p+i)->number,(p+i)->name);
            for(j=0;j<100;j++)
                printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%f",(p+i)->wanum[j],(p+i)->elnum[j],(p+i)->emoney[j]);
        }
    }
}

void DeleteFunc()
{
    int i,j,m;
    printf("删除的住户门牌号为:[ ]\b\b");
    scanf("%d",&m);
    for(i=0;i<N;i++)
        if((p+i)->number==m)
        {
            strcpy((p+i)->name,(p+j+1)->name);
            (p+i)->amoney=(p+i+1)->amoney;
            for(j=0;j<100;j++)
            {
                (p+i)->wanum[j]=(p+i+1)->wanum[j+1];
                (p+i)->elnum[j]=(p+i+1)->elnum[j+1];
                strcpy((p+i)->time[j],(p+i+1)->time(j+1));
            }
    SavedataFunc();
        }
}


编译单个文件...
--------
- 文件名: C:\Users\zqm\Documents\未命名2.22.cpp
- 编译器名: TDM-GCC 4.9.2 64-bit Release

处理 C++ 源文件...
--------
- C++ 编译器: E:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe
- 命令: g++.exe "C:\Users\zqm\Documents\未命名2.22.cpp" -o "C:\Users\zqm\Documents\未命名2.22.exe"  -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++" -L"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"E:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc
C:\Users\zqm\Documents\未命名2.22.cpp: In function 'void AdddataFunc()':
C:\Users\zqm\Documents\未命名2.22.cpp:119:5: error: 're' was not declared in this scope
     re;
     ^

C:\Users\zqm\Documents\未命名2.22.cpp: In function 'void SortdataFunc()':
C:\Users\zqm\Documents\未命名2.22.cpp:150:4: error: expected unqualified-id before '[' token
  Re[N] *temp;
    ^
C:\Users\zqm\Documents\未命名2.22.cpp:156:4: error: 'temp' was not declared in this scope
    temp=p+i;
    ^
C:\Users\zqm\Documents\未命名2.22.cpp:157:7: error: lvalue required as left operand of assignment
    p+i=p+j;
       ^
C:\Users\zqm\Documents\未命名2.22.cpp: In function 'void QuerydataFunc()':
C:\Users\zqm\Documents\未命名2.22.cpp:167:4: error: 're' was not declared in this scope
   *re;
    ^
C:\Users\zqm\Documents\未命名2.22.cpp: In function 'void DeleteFunc()':
C:\Users\zqm\Documents\未命名2.22.cpp:227:44: error: expression cannot be used as a function
     strcpy((p+i)->time[j],(p+i+1)->time(j+1));
                                            ^
2017-05-07 23:02
renkejun1942
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:不是这样
等 级:贵宾
威 望:33
帖 子:1645
专家分:5297
注 册:2016-12-1
收藏
得分:0 
最重要的一点却是依旧没改。
C的后缀是.c
.cpp是C++的后缀。

C:\Users\zqm\Documents\未命名2.22.cpp:167:4: error: 're' was not declared in this scope
   *re;

*re 的类型是什么?


[此贴子已经被作者于2017-5-7 23:11编辑过]


09:30 05/21 种下琵琶种子,能种活么?等待中……
21:50 05/27 没有发芽。
20:51 05/28 没有发芽。
23:03 05/29 没有发芽。
23:30 06/09 我有预感,要发芽了。
2017-05-07 23:06
快速回复:小区水电管理系统,有很多错误,求指点
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041184 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved