str_dup.c
来自「MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程」· C语言 代码 · 共 44 行
C
44 行
/* supply my own strdup just in case Ed Karrels Argonne National Laboratory*//* don't call str_dup -- use STRDUP */#include <stdio.h>#include <stdlib.h>#include <string.h>#include "str_dup.h"#ifdef NEEDS_STDLIB_PROTOTYPES#include "protofix.h"#endifchar *str_dup( str, line, file )char *str;int line;char *file;{ char *p; p = (char *)malloc( strlen( str )+1 ); if (!p) { fprintf( stderr, "Failed to allocate %d bytes of memory in line %d, file %s\n", (int)(strlen( str )+1), line, file ); return 0; } else { strcpy( p, str ); return p; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?