HELPLIB.HLB  —  CRTL  strcat  Example
        #include <string.h>
        #include <stdio.h>

        /* This program concatenates two strings using the strcat       */
        /* function, and then manually compares the result of strcat    */
        /* to the expected result.                                      */

        #define S1LENGTH 10
        #define S2LENGTH 8

        main()
        {
            static char s1buf[S1LENGTH + S2LENGTH] = "abcmnexyz";
            static char s2buf[] = " orthis";
            static char test1[] = "abcmnexyz orthis";

            int i;
            char *status;

            /* Take static buffer s1buf, concatenate static buffer      */
            /* s2buf to it, and compare the answer in s1buf with the    */
            /* static answer in test1.                                  */

            status = strcat(s1buf, s2buf);
            for (i = 0; i <= S1LENGTH + S2LENGTH - 2; i++) {
                /* Check for correct returned string.   */

                if (test1[i] != s1buf[i])
                    printf("error in strcat");
            }
        }
Close Help