VMS Help  —  CRTL  nl_langinfo, Example
        #include <stdio.h>
        #include <locale.h>
        #include <langinfo.h>

        /* This test sets up the British English locale, and then       */
        /* inquires on the data and time format, first day of the week, */
        /* and abbreviated first day of the week.                       */

        #include <stdlib.h>
        #include <string.h>

        int main()
        {
            char *return_val;
            char *nl_ptr;

            /* set the locale, with user supplied locale name  */

            return_val = setlocale(LC_ALL, "en_gb.iso8859-1");
            if (return_val == NULL) {
                printf("ERROR : The locale is unknown");
                exit(1);
            }
            printf("+----------------------------------------+\n");

            /* Get the date and time format from the locale.  */

            printf("D_T_FMT = ");

            /*  Compare the returned string from nl_langinfo with */
            /*  an empty string.                                  */

            if (!strcmp((nl_ptr = (char *) nl_langinfo(D_T_FMT)), "")) {

          /* The string returned was empty this could mean that either */
          /* 1) The locale does not contain a value for this item      */
          /* 2) The value for this item is an empty string             */

                printf("nl_langinfo returned an empty string\n");
            }
            else {
                /* Display the date and time format  */

                printf("%s\n", nl_ptr);
            }

        /* Get the full name for the first day of the week from locale */
           printf("DAY_1 = ");

          /*  Compare the returned string from nl_langinfo with */
          /*  an empty string.                                  */

            if (!strcmp((nl_ptr = (char *) nl_langinfo(DAY_1)), "")) {

          /* The string returned was empty this could mean that either */
          /*    1) The locale does not contain a value for the first   */
          /*       day of the week                                     */
          /*    2) The value for the first day of the week is          */
          /*       an empty string                                     */

                printf("nl_langinfo returned an empty string\n");
            }

            else {
             /* Display the full name of the first day of the week     */

                printf("%s\n", nl_ptr);
            }
  /* Get the abbreviated name for the first day of the week from locale*/

            printf("ABDAY_1 = ");

         /* Compare the returned string from nl_
 langinfo with an empty */
         /* string.                                                    */

            if (!strcmp((nl_ptr = (char *) nl_langinfo(ABDAY_1)), "")) {

         /* The string returned was empty this could mean that either  */
         /*    1) The locale does not contain a value for the first    */
         /*       day of the week                                      */
         /*    2) The value for the first day of the week is an        */
         /*       empty string                                         */

                printf("nl_langinfo returned an empty string\n");
            }

            else {

         /* Display the abbreviated name of the first day of the week  */

                printf("%s\n", nl_ptr);
           }
        }

      Running the example program produces the following result:

        +----------------------------------------+
        D_T_FMT = %a %e %b %H:%M:%S %Y
        DAY_1 = Sunday
        ABDAY_1 = Sun
Close Help