c语言整形节点打印

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>

#define COUNT  (10)

void printf_nodes(int*buf)
{
    int i = 0;
    if(buf==NULL)
    {
        printf("buf is NULL\n");
        return;
    }

    for(i=0 ;buf[i]!='?';i++)
    {
        printf("buf[%d] is %d\n",i,buf[i]);
    }

}

//0-8 ?
int main()
{
    int* buf = (int*)malloc(COUNT*sizeof(int));

    buf[0] = 0;
    buf[1] = 1;
    buf[2] = 2;
    buf[3] = 3;
    buf[4] = 4;
    buf[5] = 5;
    buf[6] = 6;
    buf[7] = 7;
    buf[8] = 8;
    buf[9] = '?';

    printf_nodes(buf);

    free(buf);

    for(;;);
    return 0;
}

  

posted @ 2020-09-26 11:08  卷哭你  阅读(153)  评论(0编辑  收藏  举报