fmemopen, open_memstream, open_wmemstream
 fmemopen, open_memstream, open_wmemstream -  open memory as stream
  SYNOPSIS
       #include <stdio.h>
       FILE *fmemopen(void *buf, size_t size, const char *mode);
       FILE *open_memstream(char **ptr, size_t *sizeloc);
       #include <wchar.h>
       FILE *open_wmemstream(wchar_t **ptr, size_t *sizeloc);
       fmemopen(), open_memstream(), open_wmemstream():
           Since glibc 2.10:
               _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
           Before glibc 2.10:
               _GNU_SOURCE
   RETURN VALUE                Upon successful completion fmemopen(), open_memstream() and open_wmemstream()
       return a FILE pointer.  Otherwise, NULL is returned and errno is set to
       indicate the error.
VERSIONS               fmemopen() and open_memstream() were already available in glibc 1.0.x.
       open_wmemstream() is available since glibc 2.4.
 Program source
       #define _GNU_SOURCE
       #include <string.h>
       #include <stdio.h>
       #include <stdlib.h>
       #define handle_error(msg) /
           do { perror(msg); exit(EXIT_FAILURE); } while (0)
       int
       main(int argc, char *argv[])
       {
           FILE *out, *in;
           int v, s;
           size_t size;
           char *ptr;
           if (argc != 2) {
            fprintf(stderr, "Usage: %s <file>/n", argv[0]);
            exit(EXIT_FAILURE);
           }
           in = fmemopen(argv[1], strlen(argv[1]), "r");
           if (in == NULL)
               handle_error("fmemopen");
           out = open_memstream(&ptr, &size);
           if (out == NULL)
               handle_error("open_memstream");
           for (;;) {
               s = fscanf(in, "%d", &v);
               if (s <= 0)
                   break;
               s = fprintf(out, "%d ", v * v);
               if (s == -1)
                   handle_error("fprintf");
           }
           fclose(in);
           fclose(out);
           printf("size=%ld; ptr=%s/n", (long) size, ptr);
           free(ptr);
           exit(EXIT_SUCCESS);
       }
  Ref: http://www.kernel.org/doc/man-pages/online/pages/man3/fmemopen.3.html
  Home: http://www.kernel.org/doc/man-pages/index.html
                이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Docker를 사용한 React 및 .NET Core 6.0 샘플 프로젝트 - 1부이 기사에서는 Entity Framework Core Code First 접근 방식을 사용하는 ASP.NET Core 6.0 WEP API의 CRUD(만들기, 읽기, 업데이트 및 삭제) 작업에 대해 설명합니다. 웹 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.