⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 va

📁 Algorithms for Image Processing and Computer Vision Source Code
💻
字号:
@c ----------------------------------------------------------------------
@node va_*, misc
@heading @code{va_start}, @code{va_end}, @code{va_arg}
@subheading Syntax

@example
#include <stdarg.h>

va_list v;
va_start(v, last-formal-arg);
va_arg(v, type)
va_end(v);
@end example

@subheading Description

These functions provide access to the variable arguments passed to
functions prototyped with the "..." symbol (like @pxref{printf}).  You
must declare a variable to hold the marker, then initialize it with
@code{va_start}.  Then, for each value you want, call @code{va_arg}
and pass it tye type of the value (for example, va_arg(v, int)).  When
you're done, call va_end to clean up.

@subheading Return Value

@code{va_arg} returns the value of the argument.

@subheading Example

@example
void sum(int x, ...)
@{
  int s = 0, i;
  va_list v;
  va_start(v, x);
  for (i=0; i<s; i++)
    s += va_arg(v, int);
  va_end(v);
  return s;
@}
@end example

void debug(char *fmt, ...)
@{
  va_list v;
  if (!do_debug) return;
  va_start(v, fmt);
  vfprintf(stderr, fmt, v);
  va_end(v);
@}

@c ----------------------------------------------------------------------
@node valloc, memory
@heading @code{valloc}
@subheading Syntax

@example
#include <stdlib.h>

void *valloc(unsigned size);
@end example

@subheading Description

This function is just like @code{malloc} (@pxref{malloc}) except that the
returned pointer is always aligned to a CPU page boundary.  This
alignment is rarely useful in djgpp. 

@subheading Return Value

A pointer to a newly allocated block of memory. 

@subheading Example

@example
char *page = valloc(getpagesize());
@end example

⌨️ 快捷键说明

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