I would suggest you prefer strncat to strcat. strncat is the secure sister of strcat:
Quote:
char * strncat ( char * destination, char * source, size_t num ); Append characters from string
Appends the first num characters of source to destination, plus a terminating null-character. If the length of the C string in source is less than num, only the content up to the terminating null-character is copied.
usage of strncat is the same as strcat. The only difference is that strncat has an aditional third argument, that you use to tell the function the maximum amount of characters that should be copied to the destination buffer. This is very important to prevent your programs being vulnerable to buffer overflow errors.
Last edited by Corona688; 03-23-2012 at 03:44 PM..
Reason: horizontally stretching the window
These 2 Users Gave Thanks to pflynn For This Post:
What does the system call "dup" do?
What is the difference between dup and dup2
I have a fair idea of what it does but I am confused when its coming down to the exact details...
Please help me!:confused: (2 Replies)
open, creat, read, write, lseek and close
Are they all primitive?
:confused:
*Another Question: is there a different between a system call, and an i/o system call? (2 Replies)
Hi,
I'm new to UNIX system calls. Can someone share your knowledge as to how exactly system calls should be executed?
Can they be typed like commands such as mkdir on the terminal itself? Also, are there any websites which will show me an example of the output to expect when a system call like... (1 Reply)
hi, i'm a noob
i have a quuestion: is possible to call and run the bash script by c++ program?
if so, is it posible in grafic? specially Qt ?
thanks (8 Replies)
Hello,
how would i be able to call ps in C programming?
thanks,
---------- Post updated at 01:39 AM ---------- Previous update was at 01:31 AM ----------
here's the complete system call, ps -o pid -p %d, getpit() (2 Replies)
Discussion started by: l flipboi l
2 Replies
LEARN ABOUT OSX
strcat
STRCAT(3) BSD Library Functions Manual STRCAT(3)NAME
strcat, strncat -- concatenate strings
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <string.h>
char *
strcat(char *restrict s1, const char *restrict s2);
char *
strncat(char *restrict s1, const char *restrict s2, size_t n);
DESCRIPTION
The strcat() and strncat() functions append a copy of the null-terminated string s2 to the end of the null-terminated string s1, then add a
terminating '