strstuff.c

来自「su 的源代码库」· C语言 代码 · 共 87 行

C
87
字号
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       */#include "cwp.h"/*********************** self documentation **********************//******************************************************************STRSTUFF -- STRing manuplation subscwp_strdup -  duplicate a stringstrchop - chop off the tail end of a string "s" after a "," returning	  the front part of "s" as "t".******************************************************************Input:char *str	input string	Output:noneReturns:char *	  duplicated string******************************************************************Notes:This local definition of strdup is necessary because some systemsdo not have it.******************************************************************Author: John Stockwell, Spring 2000.******************************************************************//**************** end self doc ********************************/char *cwp_strdup(char *str)/******************************************************************cwp_strdup -  duplicate a string******************************************************************Input:char *str	input string	Output:noneReturns:char *copy      copy of string******************************************************************Notes:This local definition of strdup is necessary because some systemsdo not have it.******************************************************************Author: John Stockwell, Spring 2000.******************************************************************/{	int len;	char *copy;	len = strlen(str) + 1;	if (!(copy = malloc((unsigned int) len)))		return ((char *) NULL);	memcpy(copy,str, len);	return (copy);}void strchop(char *s, char *t)/***********************************************************************strchop - chop off the tail end of a string "s" after a "," returning	  the front part of "s" as "t".************************************************************************Notes:Based on strcpy in Kernighan and Ritchie's C [ANSI C] book, p. 106.************************************************************************Author: CWP: John Stockwell and Jack K. Cohen, July 1995***********************************************************************/{	while ( (*s != ',') && (*s != '\0') ) {		 *t++ = *s++;	}	*t='\0';}

⌨️ 快捷键说明

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