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