Blame manual/examples/memopen.c
|
Packit Service |
82fcde |
/* String Streams
|
|
Packit Service |
82fcde |
Copyright (C) 1991-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
This program is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU General Public License
|
|
Packit Service |
82fcde |
as published by the Free Software Foundation; either version 2
|
|
Packit Service |
82fcde |
of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
82fcde |
GNU General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU General Public License
|
|
Packit Service |
82fcde |
along with this program; if not, if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <stdio.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static char buffer[] = "foobar";
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
main (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
int ch;
|
|
Packit Service |
82fcde |
FILE *stream;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
stream = fmemopen (buffer, strlen (buffer), "r");
|
|
Packit Service |
82fcde |
while ((ch = fgetc (stream)) != EOF)
|
|
Packit Service |
82fcde |
printf ("Got %c\n", ch);
|
|
Packit Service |
82fcde |
fclose (stream);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return 0;
|
|
Packit Service |
82fcde |
}
|