请问下为什么引用了和 ,getdate()还是有错误,用vs2010写的

时间:2020-12-15 22:59:38
struct date
{

}today;结构体里面是空的会报错么,别人的源代码是 struct date today,但这样写会报错,我就改成struct date{  }today,不知道这样会不会有错 

6 个解决方案

#1


不会出错    别人的写法应该是
 

typedef struct date
{

}today;

#2


引用 1 楼 q3733353520 的回复:
不会出错    别人的写法应该是
 

typedef struct date
{

}today;
,嗯,这个已经弄好了,那为什么引用了<time.h>和<dos.h>getdate()还是有错误

#3


 struct tm *getdate(const char *string);

The function getdate() converts a string representation of a  date  and
       time,  contained in the buffer pointed to by string, into a broken-down
       time.  The broken-down time is stored in a tm structure, and a  pointer
       to  this  structure is returned as the function result.  This tm struc‐
       ture is allocated in static storage, and consequently it will be  over‐
       written by further calls to getdate().

RETURN VALUE
       When successful, getdate() returns a pointer to a  struct  tm.   Other‐
       wise,  it  returns NULL and sets the global variable getdate_err to one
       of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r() returns 0; on error it returns one of the  error
       numbers shown below.
Program source
      
 #define _GNU_SOURCE 500
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct tm *tmp;
           int j;

           for (j = 1; j < argc; j++) {
               tmp = getdate(argv[j]);

               if (tmp == NULL) {
                   printf("Call %d failed; getdate_err = %d\n", j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

          



#4


引用 3 楼 q3733353520 的回复:
 struct tm *getdate(const char *string);

The function getdate() converts a string representation of a  date  and
       time,  contained in the buffer pointed to by string, into a broken-down
       time.  The broken-down time is stored in a tm structure, and a  pointer
       to  this  structure is returned as the function result.  This tm struc‐
       ture is allocated in static storage, and consequently it will be  over‐
       written by further calls to getdate().

RETURN VALUE
       When successful, getdate() returns a pointer to a  struct  tm.   Other‐
       wise,  it  returns NULL and sets the global variable getdate_err to one
       of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r() returns 0; on error it returns one of the  error
       numbers shown below.
Program source
      
 #define _GNU_SOURCE 500
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct tm *tmp;
           int j;

           for (j = 1; j < argc; j++) {
               tmp = getdate(argv[j]);

               if (tmp == NULL) {
                   printf("Call %d failed; getdate_err = %d\n", j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

          
  大哥,,这是啥意思。。。

#5


引用 4 楼 alone857567508 的回复:
Quote: 引用 3 楼 q3733353520 的回复:

 struct tm *getdate(const char *string);

The function getdate() converts a string representation of a  date  and
       time,  contained in the buffer pointed to by string, into a broken-down
       time.  The broken-down time is stored in a tm structure, and a  pointer
       to  this  structure is returned as the function result.  This tm struc‐
       ture is allocated in static storage, and consequently it will be  over‐
       written by further calls to getdate().

RETURN VALUE
       When successful, getdate() returns a pointer to a  struct  tm.   Other‐
       wise,  it  returns NULL and sets the global variable getdate_err to one
       of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r() returns 0; on error it returns one of the  error
       numbers shown below.
Program source
      
 #define _GNU_SOURCE 500
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct tm *tmp;
           int j;

           for (j = 1; j < argc; j++) {
               tmp = getdate(argv[j]);

               if (tmp == NULL) {
                   printf("Call %d failed; getdate_err = %d\n", j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

          
  大哥,,这是啥意思。。。

你说的getdata的用法

#6


引用 5 楼 q3733353520 的回复:
Quote: 引用 4 楼 alone857567508 的回复:

Quote: 引用 3 楼 q3733353520 的回复:

 struct tm *getdate(const char *string);

The function getdate() converts a string representation of a  date  and
       time,  contained in the buffer pointed to by string, into a broken-down
       time.  The broken-down time is stored in a tm structure, and a  pointer
       to  this  structure is returned as the function result.  This tm struc‐
       ture is allocated in static storage, and consequently it will be  over‐
       written by further calls to getdate().

RETURN VALUE
       When successful, getdate() returns a pointer to a  struct  tm.   Other‐
       wise,  it  returns NULL and sets the global variable getdate_err to one
       of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r() returns 0; on error it returns one of the  error
       numbers shown below.
Program source
      
 #define _GNU_SOURCE 500
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct tm *tmp;
           int j;

           for (j = 1; j < argc; j++) {
               tmp = getdate(argv[j]);

               if (tmp == NULL) {
                   printf("Call %d failed; getdate_err = %d\n", j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

          
  大哥,,这是啥意思。。。

你说的getdata的用法


额,错了,是getdate

#1


不会出错    别人的写法应该是
 

typedef struct date
{

}today;

#2


引用 1 楼 q3733353520 的回复:
不会出错    别人的写法应该是
 

typedef struct date
{

}today;
,嗯,这个已经弄好了,那为什么引用了<time.h>和<dos.h>getdate()还是有错误

#3


 struct tm *getdate(const char *string);

The function getdate() converts a string representation of a  date  and
       time,  contained in the buffer pointed to by string, into a broken-down
       time.  The broken-down time is stored in a tm structure, and a  pointer
       to  this  structure is returned as the function result.  This tm struc‐
       ture is allocated in static storage, and consequently it will be  over‐
       written by further calls to getdate().

RETURN VALUE
       When successful, getdate() returns a pointer to a  struct  tm.   Other‐
       wise,  it  returns NULL and sets the global variable getdate_err to one
       of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r() returns 0; on error it returns one of the  error
       numbers shown below.
Program source
      
 #define _GNU_SOURCE 500
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct tm *tmp;
           int j;

           for (j = 1; j < argc; j++) {
               tmp = getdate(argv[j]);

               if (tmp == NULL) {
                   printf("Call %d failed; getdate_err = %d\n", j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

          



#4


引用 3 楼 q3733353520 的回复:
 struct tm *getdate(const char *string);

The function getdate() converts a string representation of a  date  and
       time,  contained in the buffer pointed to by string, into a broken-down
       time.  The broken-down time is stored in a tm structure, and a  pointer
       to  this  structure is returned as the function result.  This tm struc‐
       ture is allocated in static storage, and consequently it will be  over‐
       written by further calls to getdate().

RETURN VALUE
       When successful, getdate() returns a pointer to a  struct  tm.   Other‐
       wise,  it  returns NULL and sets the global variable getdate_err to one
       of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r() returns 0; on error it returns one of the  error
       numbers shown below.
Program source
      
 #define _GNU_SOURCE 500
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct tm *tmp;
           int j;

           for (j = 1; j < argc; j++) {
               tmp = getdate(argv[j]);

               if (tmp == NULL) {
                   printf("Call %d failed; getdate_err = %d\n", j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

          
  大哥,,这是啥意思。。。

#5


引用 4 楼 alone857567508 的回复:
Quote: 引用 3 楼 q3733353520 的回复:

 struct tm *getdate(const char *string);

The function getdate() converts a string representation of a  date  and
       time,  contained in the buffer pointed to by string, into a broken-down
       time.  The broken-down time is stored in a tm structure, and a  pointer
       to  this  structure is returned as the function result.  This tm struc‐
       ture is allocated in static storage, and consequently it will be  over‐
       written by further calls to getdate().

RETURN VALUE
       When successful, getdate() returns a pointer to a  struct  tm.   Other‐
       wise,  it  returns NULL and sets the global variable getdate_err to one
       of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r() returns 0; on error it returns one of the  error
       numbers shown below.
Program source
      
 #define _GNU_SOURCE 500
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct tm *tmp;
           int j;

           for (j = 1; j < argc; j++) {
               tmp = getdate(argv[j]);

               if (tmp == NULL) {
                   printf("Call %d failed; getdate_err = %d\n", j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

          
  大哥,,这是啥意思。。。

你说的getdata的用法

#6


引用 5 楼 q3733353520 的回复:
Quote: 引用 4 楼 alone857567508 的回复:

Quote: 引用 3 楼 q3733353520 的回复:

 struct tm *getdate(const char *string);

The function getdate() converts a string representation of a  date  and
       time,  contained in the buffer pointed to by string, into a broken-down
       time.  The broken-down time is stored in a tm structure, and a  pointer
       to  this  structure is returned as the function result.  This tm struc‐
       ture is allocated in static storage, and consequently it will be  over‐
       written by further calls to getdate().

RETURN VALUE
       When successful, getdate() returns a pointer to a  struct  tm.   Other‐
       wise,  it  returns NULL and sets the global variable getdate_err to one
       of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r() returns 0; on error it returns one of the  error
       numbers shown below.
Program source
      
 #define _GNU_SOURCE 500
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct tm *tmp;
           int j;

           for (j = 1; j < argc; j++) {
               tmp = getdate(argv[j]);

               if (tmp == NULL) {
                   printf("Call %d failed; getdate_err = %d\n", j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

          
  大哥,,这是啥意思。。。

你说的getdata的用法


额,错了,是getdate