Syntax
#include <nl_types.h> char *catgets(nl_catd catd, int set_id, int msg_id, const char *s);Description
The catgets subroutine retrieves a message from a catalog and constructs a message based on the set_id + msg_id + message. If the catgets subroutine finds the specified message, it loads it into an internal character string buffer, ends the message string with a null character, and returns a pointer to the buffer.
The returned pointer is used to reference the buffer and display the message. However, the buffer cannot be referenced after the catalog is closed.
The parameters are:
catd
If the catgets subroutine is unsuccessful for any reason, it returns the user-supplied default message string specified by the s parameter.
This example opens a message file with the name contained in tcat and prints out the message associated with set number in setno and the message number in msgno.
#include <stdio.h>#include <nl_types.h> char *catg(char *tcat, int setno, int msgno, char *def) { nl_catd catd; /* Catalog descriptor. */ if ((catd = catopen(tcat, 0)) == CATD_ERR) { printf("Unable to load specified catalog. \n"); exit (1); } printf("ERROR MESSAGE : %s\n", catgets(catd, setno, msgno, def)); if (catclose(catd) == -1) perror("Error when trying to close catalog file"); }Related Information