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

📄 strsub.c

📁 一个很好的分子动力学程序
💻 C
字号:
						/**********************************/						/**  STRING PARSING SUBROUTINES  **/						/**********************************/#include <stdlib.h>#include <ctype.h>#include "strsub.h"/************************************************************************Defines************************************************************************/#define BOOLEAN int#define TRUE    1#define FALSE   0/************************************************************************Module Variables************************************************************************//*  String holding White Space Characters  *//*  PULLS AND RETURNS POINTER TO FIRST TOKEN  */char *strhed (char **tadd){   char *head, *sep, *tail;   tail = (*tadd);   /* FIND FIRST NONBLANK CHARACTER  */   while (   (*tail)          && ( (*tail)==' ' || (*tail)=='\t' || (*tail)=='\n' )  )             tail++;   /* FIND NEXT WHITE SPACE CHARCTER  */   head = (sep = tail);   while ((*sep) && (*sep)!=' ' && (*sep)!='\n' && (*sep)!='\t') sep++;   /* INSERT NULL CHARACTER  */   tail = sep;   if (*sep)		{ (*sep) = 0;		  tail++;		}	/*  RETURN FIRST TOKEN  */	SkipWhiteSpace (&tail);	*tadd = tail;	return(head);}/*  COMPARES TWO STRINGS BUT IGNORES CASE  *//*  RETURNS -1 if a< b                     *//*           0 if a==b                     *//*           1 if a> b                     */int strcmpi (const char *a, const char *b) {   int flag;   char inc = 'a' - 'A';   char ta, tb;   do {      ta = *a;      tb = *b;      flag = (ta==tb);      if (!flag) {         if (ta>='A' && ta<='Z')            ta += inc;         if (tb>='A' && tb<='Z')            tb += inc;   ;         flag = (ta==tb);      }   } while (flag && *a++!=0 && *b++!=0);   if (flag)      return(0);   if (ta<tb)      return(-1);   return( 1);}/*  PULLS LEADING TOKEN:  EVALUATES AS CONSTANT - RETURNS DOUBLE  */double dblstr (char **s) {	char *t = strhed (s);	if (*t==0)		return (0.0);	else		return (atof(t));}/*  PULLS LEADING TOKEN:  EVALUATES AS CONSTANT - RETURNS INT  */int intstr (char **s) {	char *t = strhed (s);   if (*t==0)      return (0);   else      return (atoi(t));}/*  PULLS LEADING TOKEN:  EVALUATES AS CONSTANT - RETURNS LONG  */long lngstr (char **s) {   char *t = strhed (s);   if (*t==0)      return (0L);   else      return (atol(t));}/*  CONVERTS STRING TO UPPER CASE  */void   upstr   (char   *t   ) {   while (*t!=0) {      *t = toupper(*t);      t++;   }}/*  BREAKS STRING INTO LINES ACCORDING TO ';' OR '\n'  */char *strlin (char **tadd){   char *head, *tail;   head = tail = *tadd;   /* FIND FIRST SEPARATOR  (; or \n)  */   while (   *tail && *tail!=';' && *tail!='\n')      tail++;   /* INSERT NULL CHARACTER  */   if (*tail)   {      *tail=0;      tail++;   }   /*  RETURN FIRST TOKEN  */   *tadd = tail;   return(head);}/*  Returns True if first non-whitespace characters is in string  */BOOLEAN IsComment (char *InputString, char *CommentChars)   {   char LeadingChar;   int  TestIndex;   /*  Find first non-white space character  */   SkipWhiteSpace (&InputString);   LeadingChar = InputString[0];   /*  Scan list of comment characters to see if leading character belongs  */   TestIndex = 0;   while   (   CommentChars[TestIndex]!='\0' &&   CommentChars[TestIndex]!=LeadingChar   )      TestIndex++;   /*  Return true if matching characters not string terminatore  */   return (CommentChars[TestIndex] != '\0');   }BOOLEAN IsBlank (char *InputString)   {   SkipWhiteSpace (&InputString);   if (InputString[0]=='\0')      return TRUE;   else      return FALSE;   }void SkipWhiteSpace (char **s)   {   while   (   **s == ' '  ||   **s == '\n' ||   **s == '\t' ||   **s == '\r' ||   **s == '\b' ||   **s == '\f' ||   **s == '\v'   )      (*s)++;   }#ifdef ULTRIXchar *strdup (char *s){   char *t = (char *) calloc (strlen(s)+1, sizeof(char));   strcpy (t, s);   return (t);}#endif

⌨️ 快捷键说明

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