首页 > 用户发贴区 > 编程问题提问区 > 关于BUG的疑问
2008
09-24

在执行c文件后得到以下warning信息,请教各位前辈
warning #2513-D : a value of type “char” cannot be assigned to an entity of type “char *”

warning #2174-D: expression has no effect
NULL

麻烦各位了


关于BUG的疑问》有 1 条评论

  1. mxljared 说:

    晕,没有人帮忙啊?
    帮忙看看吧下面是源代码
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <errno.h>
    #include “optargv.h”

    #define BUF_SIZ 1024
    #define LEN 7
    #define SIZE 2
    int main (int argc, char *argv[])
    {

    FILE *fp_in = (FILE *)NULL;
    FILE *fp_out = (FILE *)NULL;

    char filename [ BUF_SIZ ];
    char linebuf  [ BUF_SIZ ];
    char outbuf   [ BUF_SIZ ];
    char hiniti [7];
    char NEN [2];
    char GETU [2];
    char HI  [2];

    char *delim = ” “;
    char **argvs;
    char *time =”";

    char *hiduke =”";
    char *nen;
    char *nen1;
    char *getu;
    char *getu1;
    char *hi;
    char *hi1;
    char Y;
    char M;
    char D;

    int numtokens;
    int cnt = 0;
    char index;

    if (argc != 2)
    {
            printf(“usage: %s filenaname”, argv[0]);
            return -1;
    }

    if(fp_in ==(FILE *)NULL)
    {
          printf (“ERROR: open file error!”);
          printf (“usage: %  filenanmn”,argv[0]);
    }

    fp_out =fopen(filename, “w”);
    if (fp_out == (FILE *)NULL)
    {
           printf (“ERROR: open file error!”);
           printf (“useage:%s filename”,  argv[0]);
           return -1;
    }

    for (;;)
    {

           if (fgets(linebuf,BUF_SIZ,fp_in) ==NULL)

                  break;
    }

           numtokens =makeargv( linebuf,delim, &argvs);
           memset(outbuf,’\0′,BUF_SIZ);

           if(numtokens >=2)
                 if ((strcomp(argvs[0], “HP-UX”) == 0))
                 {
                         printf(“argvs[5]:%s\n”,argvs[5]);
                         hiduke = argvs[5];
                         /*strcart(hiniti,hiduke);*/
                         nen =argv[5][6];
                         nen1 =&argvs[5][7];
                         strcat(hiniti,nen);
                         strcar(hiniti,nen1);
                         getu = &argvs[5][0];
                         getu1 = &argvs[5][1];
                         strcat(hiniti,getu);
                         strcat(hiniti,getu1);
                         hi = &argvs[5][3];
                         hi1 = &argvs[5][4];
                         strcat(hiniti,hi1);

                         continue;
                   }
                   if ((strcmp(argvs[0], “Average”) == 0))
                   {
                   continue;
                   }
                   if ((strlen(argvs[0] == 8) && (argvs[0][2] ==’:') && (argvs[0][5] ==

                   {

                           strcat(outbuf,hiniti);
                           strcat(outbuf,”,”);
                           time =argvs[0];
    } else {
           strcat(outbuf,hiniti);
           strcat(outbuf,”,”);
           strcat(outbuf,time);
           stecat(outbuf,”,”)
    }
    fou (cnt=0; cnt < (numtokens – 1); cnt++)
            strcat(outbuf,argvs[cnt]);
            strcat(outbuf,”,”);
    }
    strcat(outbuf,argvs[cnt]);
    }else {
          continue;
    }
    printf(“argvs[0]:%s\n ,argvs[0]);
    printf(“numtokens:%d\n ,numutokens);
    printf(“line_in:%s”,linebuf);
    printf(“line_out:%\n” ,outbuf):

    fputs(outbuf, fp_out);
    }

    fclose(fp_out);
    fclose(fp_in);
    return 0;

    }

留下一个回复