/************************************************************************ * * * Copyright Digital Equipment Corporation 1998. All rights reserved. * * * * Restricted Rights: Use, duplication, or disclosure by the U.S. * * Government is subject to restrictions as set forth in subparagraph * * (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR * * 52.227-14 Alt. III, as applicable. * * * * This software is proprietary to and embodies the confidential * * technology of Digital Equipment Corporation. Possession, use, or * * copying of this software and media is authorized only pursuant to a * * valid written license from Digital or an authorized sublicensor. * * * ************************************************************************/ /* strcat_example.c */ #include #include /* 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"); } }