⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time_stamp.c

📁 KNN algorithm, and related
💻 C
字号:
/* ----------------------------- MNI Header -----------------------------------@NAME       : time_stamp.c@DESCRIPTION: File containing routine to create a time stamp string.@METHOD     : @CREATED    : February 1, 1993 (Peter Neelin)@MODIFIED   :  * $Log: time_stamp.c,v $ * Revision 1.1.1.1  2002/03/20 22:16:34  jason * first autoconfiscated version that compiles under linux gcc 3 * * Revision 6.1  2002/01/14 21:28:26  neelin * Moved nd_loop, voxel_loop, ParseArgv and time_stamp from ../progs/Proglib * in order to include them in the main minc library. * * Revision 6.2  1999/10/19 15:57:18  neelin * Fixed log message containing log substitution * * Revision 6.1  1999/10/19 14:45:14  neelin * Fixed Log subsitutions for CVS * * Revision 6.0  1997/09/12 13:23:41  neelin * Release of minc version 0.6 * * Revision 5.0  1997/08/21  13:24:41  neelin * Release of minc version 0.5 * * Revision 4.0  1997/05/07  20:00:50  neelin * Release of minc version 0.4 * * Revision 3.0  1995/05/15  19:31:35  neelin * Release of minc version 0.3 * * Revision 2.0  1994/09/28  10:34:30  neelin * Release of minc version 0.2 * * Revision 1.4  94/09/28  10:34:20  neelin * Pre-release *  * Revision 1.3  93/08/04  13:03:56  neelin * Added RCS Log to keep track of modifications in source *@COPYRIGHT  :              Copyright 1993 Peter Neelin, McConnell Brain Imaging Centre,               Montreal Neurological Institute, McGill University.              Permission to use, copy, modify, and distribute this              software and its documentation for any purpose and without              fee is hereby granted, provided that the above copyright              notice appear in all copies.  The author and McGill University              make no representations about the suitability of this              software for any purpose.  It is provided "as is" without              express or implied warranty.---------------------------------------------------------------------------- */#include <stdlib.h>#include <string.h>#include <time.h>#include <time_stamp.h>#ifndef lintstatic char rcsid[]="$Header: /software/source/INSECT/classify/time_stamp.c,v 1.1.1.1 2002/03/20 22:16:34 jason Exp $";#endif/* ----------------------------- MNI Header -----------------------------------@NAME       : time_stamp@INPUT      : argc - number of arguments              argv - list of arguments@OUTPUT     : @RETURNS    : pointer to string containing time stamp.@DESCRIPTION: Function to produce a time stamp string for a program.              Returns a string of the form "date > command". The command              is simply the concatenation of argv elements.@METHOD     : @GLOBALS    : @CALLS      : @CREATED    : February 1, 1993 (Peter Neelin)@MODIFIED   : ---------------------------------------------------------------------------- */char *time_stamp(int argc, char *argv[]){   char *str, *the_time;   int length, i, last;   static char separator[]={">>>"};   time_t timer;   /* Get the time, overwriting newline */   timer = time(NULL);   the_time = ctime(&timer);   /* Get the total length of the string and allocate space */   length=strlen(the_time) + strlen(separator) + 2;   for(i=0; i<argc; i++) {      length += strlen(argv[i]) + 1;   }   str = malloc(length);   /* Copy the time and separator */   (void) strcpy(str, the_time);   str[strlen(str)-1]='\0';   (void) strcat(str, separator);   /* Copy the program name and arguments */   for (i=0; i<argc; i++) {      last = strlen(str);      str[last]=' ';      str[last+1]='\0';      (void) strcat(str, argv[i]);   }   /* Add a terminating newline */   last = strlen(str);   str[last]='\n';   str[last+1]='\0';   return str;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -