C Standard Libraries C++

ispunct()

Declaration

int ispunct(int iChar);

Description

This function returns a non-zero int value to indicate true if the passed in value, iChar, is apunctuation character in the ASCII table. Otherwise, the function returns zero. The ranges for which this function returns a non-zero result are [33, 47], [58, 64], [91, 96], and [123, 126].

Example

#include <iostream>
#include <cctype>

int main() {
    using namespace std;

    // Output the column headings
    cout << "    ";
    for (int iIndex = 0; iIndex < 16; ++iIndex) {
        if (iIndex < 10) {
            cout << " ";
        }
        cout << " " << iIndex;
    }
    cout << endl << endl;

    for (int iIndex = 0; iIndex < 256; ++iIndex) {
        // Output the row heading every 16 places
        if ((iIndex) % 16 == 0) {
            if (iIndex < 10) {
                cout << "  ";
            } else if (iIndex < 100) {
                cout << " ";
            }
            cout << iIndex << " ";
        }
        cout << "  " << (bool)ispunct(iIndex);
        // Add an endline every 16 characters
        if ((iIndex) % 16 == 15) {
            cout << endl;
        }
    }
    return 0;
}

Output

ispunct() Output
 

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