]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/81395.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_filebuf / sgetn / char / 81395.cc
CommitLineData
a945c346 1// Copyright (C) 2017-2024 Free Software Foundation, Inc.
fddcd19a
JW
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
1f78c47b 18// { dg-require-fileio "" }
fddcd19a
JW
19
20// PR libstdc++/81395
21
22#include <fstream>
23#include <cstring> // for std::memset
24#include <cstdio> // For BUFSIZ
25
26using std::memset;
27
28int main()
29{
30 {
31 std::filebuf fb;
32 fb.open("test.txt", std::ios::out);
33 char data[BUFSIZ];
34 memset(data, 'A', sizeof(data));
35 fb.sputn(data, sizeof(data));
36 }
37
38 std::filebuf fb;
39 fb.open("test.txt", std::ios::in|std::ios::out);
40 char buf[BUFSIZ];
41 memset(buf, 0, sizeof(buf));
42 fb.sgetn(buf, sizeof(buf));
43 // Switch from reading to writing without seeking first:
44 fb.sputn("B", 1);
45 fb.pubsync();
46}