C Standard Libraries C++

puts()

Declaration

int puts(const char *kcpString);

Description

This function outputs a null-terminated string to the standard output stream "stdout." The final null character '0' is replaced by an endline '\n' in the output stream. The function returns a nonnegative value if successful and a negative value if the function call fails.

Example

#include <cstdio>

int main()
{
    // Write to stdout.
    int iRet = puts("Write a string to stdout");

    // Check whether or not some characters were written
    if (iRet == EOF) {
        perror("puts() call failed");
    }

    return 0;
}

Output

puts() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.