關於path alloc函式(APUE)

2022-08-30 14:27:10 字數 1062 閱讀 7844

在apue的某些版本中,在例子4-7和4-9中用到的函式path_alloc()函式,許多人直接把例題輸入後發現並不能編譯,這是由於path_alloc()函式的原因,因此,我們需要將這個函式補齊。

我從網上查了一下,其中有好多的答案是從apue的老版本中的解決方法,如下:

figure 2.15. dynamically allocate space for a pathname

#include "apue.h"

#include

#include

#ifdef   path_max

static int   pathmax = path_max;

#else

static int   pathmax = 0;

#endif

#define susv3 200112l

static long posix_version = 0;

/* if path_max is indeterminate, no guarantee this is adequate */

#define path_max_guess   1024

char *

path_alloc(int *sizep) /* also return allocated size, if nonnull */

else

} if (posix_version < susv3)

size = pathmax + 1;

else

size = pathmax;

if ((ptr = malloc(size)) == null)

err_sys("malloc error for pathname");

if (sizep != null)

*sizep = size;

return(ptr);

} 另外,還發現乙個簡單的解決方法,當然,這個解決方法只是簡單的定義path_alloc()這個函式,但是,可以使我們的程式正常的執行...

char*path_alloc(int* size)

關於path alloc 函式(APUE)

鏈結為 在apue的某些版本中,在例子4 7和4 9中用到的函式path alloc 函式,許多人直接把例題輸入後發現並不能編譯,這是由於path alloc 函式的原因,因此,我們需要將這個函式補齊。我從網上查了一下,其中有好多的答案是從apue的老版本中的解決方法,如下 figure 2.15....

關於path alloc函式(APUE)

include apue.h include include ifdef path max static int pathmax path max else static int pathmax 0 endif define susv3 200112l static long posix versi...

hgdb 實現Oracle pivo函式(APP)

目錄 環境文件用途 詳細資訊 環境系統平台 microsoft windows 64 bit 10 版本 4.3.2 文件用途 瀚高資料庫實現oracle中的多行轉列 詳細資訊 with temp as select 四川省 nation 成都市 city,第一 ranking from dual ...