info > A

📖 Introduction

This package makes the C formatted output routines (fprintf et al.) usable in C++ programs, for use with the <string> strings and the <iostream> streams.

It allows to write code like:

cerr << autosprintf ("syntax error in %s:%d: %s", filename, line, errstring);

instead of:

cerr << "syntax error in " << filename << ":" << line << ": " << errstring;

Benefits:

🚀 Quick Reference

Use CaseCommandDescription
📝 Format a string with printf-like syntaxautosprintf(format, ...)Returns a std::string with formatted output.
🔗 Output to streamstream << autosprintf(...)Uses operator<< to insert formatted string into an ostream.
📄 Convert to C string(char *)autosprintf(...)Returns a freshly allocated copy (must be freed with delete[]).
🔧 Include in source#include "autosprintf.h"Include the class definition.
🔗 Use namespaceusing gnu::autosprintf;Allows use without gnu:: prefix.
📦 Link with library-lasprintf or @LIBASPRINTF@Link against libasprintf.

🏷️ Class autosprintf

An instance of class autosprintf just contains a string with the formatted output result. Such an instance is usually allocated as an automatic storage variable (on the stack), not with new on the heap.

🔧 Using autosprintf in own programs

To use the autosprintf class, add to your source code:

#include "autosprintf.h"
using gnu::autosprintf;

The include file defines the class in namespace gnu. The using statement allows use without the gnu:: prefix.

When linking, link with libasprintf. In projects using GNU autoconf, add AC_LIB_LINKFLAGS([asprintf]) to configure.in or configure.ac, and use the @LIBASPRINTF@ Makefile variable.

📄 Licenses

The files of this package are covered by the licenses indicated in each particular file or directory. Summary:

🔗 GNU Lesser General Public License

Version 2.1, February 1999. Copyright (C) 1991, 1999 Free Software Foundation, Inc.

This is the first released version of the Lesser GPL. It is the successor of the GNU Library Public License, version 2.

Full license text: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html

🔗 GNU General Public License

Version 2, June 1991. Copyright (C) 1989, 1991 Free Software Foundation, Inc.

Full license text: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

🔗 GNU Free Documentation License

Version 1.2, November 2002. Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.

Full license text: https://www.gnu.org/licenses/old-licenses/fdl-1.2.html

A
📖 Introduction 🚀 Quick Reference 🏷️ Class autosprintf 🔧 Using autosprintf in own programs 📄 Licenses
🔗 GNU Lesser General Public License 🔗 GNU General Public License 🔗 GNU Free Documentation License

Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-14 20:33 @2600:1f28:365:80b0:4d23:66fa:c2bb:7bae
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^