📄 strstuff.c
字号:
/* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -