c

来自「C程序设计经典900例.zip」· 代码 · 共 32 行

TXT
32
字号
#include <stdio.h>
#include <malloc.h>

void some_function(size_t size)
 {
   int i;

   char *pointer;

   char stack_fix[1];
   stack_fix[0] = NULL;

   if ((pointer = alloca(size)) == NULL)
     printf("Error allocating %u bytes from the stack\n", size);
   else
     {
       for (i = 0; i < size; i++)    
         pointer[i] = i;
       printf("Allocatd and used a buffer of %u bytes\n", size);
     }
 }


void main(void)
 {
   some_function(1000);
   some_function(32000);
   some_function(65000);
 }


⌨️ 快捷键说明

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