The stcat() function
The stcat() function concatenates one null-terminated string to the end of another.
Syntax
void stcat(s, dest)
char *s, *dest;
- s
- A pointer to the start of the string that stcat() places at the end of the destination string.
- dest
- A pointer to the start of the null-terminated destination string.
Example
This sample program is in the stcat.ec file
in the demo directory.
/*
* stcat.ec *
This program uses stcat() to append user input to a SELECT statement.
*/
#include <stdio.h>
/*
* Declare a variable large enough to hold
* the select statement + the value for customer_num entered from the terminal.
*/
char selstmt[80] = "select fname, lname from customer where customer_num = ";
main()
{
char custno[11];
printf("STCAT Sample ESQL Program running.\n\n");
printf("Initial SELECT string:\n '%s'\n", selstmt);
printf("\nEnter Customer #: ");
gets(custno);
/*
* Add custno to "select statement"
*/
printf("\nCalling stcat(custno, selstmt)\n");
stcat(custno, selstmt);
printf("SELECT string is:\n '%s'\n", selstmt);
printf("\nSTCAT Sample Program over.\n\n");
}
Output
STCAT Sample ESQL Program running.
Initial SELECT string:
'select fname, lname from customer where customer_num = '
Enter Customer #: 104
Calling stcat(custno, selstmt)
SELECT string is:
'select fname, lname from customer where customer_num = 104'
STCAT Sample Program over.