Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

strncat(9) [suse man page]

STRNCAT(9)						     Basic C Library Functions							STRNCAT(9)

NAME
strncat - Append a length-limited, NUL-terminated string to another SYNOPSIS
char * strncat(char * dest, const char * src, size_t count); ARGUMENTS
dest The string to be appended to src The string to append to it count The maximum numbers of bytes to copy DESCRIPTION
Note that in contrast to strncpy, strncat ensures the result is terminated. COPYRIGHT
Kernel Hackers Manual 2.6. July 2010 STRNCAT(9)

Check Out this Related Man Page

STRCAT(3)						     Linux Programmer's Manual							 STRCAT(3)

NAME
strcat, strncat - concatenate two strings SYNOPSIS
#include <string.h> char *strcat(char *dest, const char *src); char *strncat(char *dest, const char *src, size_t n); DESCRIPTION
The strcat() function appends the src string to the dest string, overwriting the null byte ('') at the end of dest, and then adds a ter- minating null byte. The strings may not overlap, and the dest string must have enough space for the result. The strncat() function is similar, except that * it will use at most n characters from src; and * src does not need to be null-terminated if it contains n or more characters. As with strcat(), the resulting string in dest is always null-terminated. If src contains n or more characters, strncat() writes n+1 characters to dest (n from src plus the terminating null byte). Therefore, the size of dest must be at least strlen(dest)+n+1. A simple implementation of strncat() might be: char* strncat(char *dest, const char *src, size_t n) { size_t dest_len = strlen(dest); size_t i; for (i = 0 ; i < n && src[i] != '' ; i++) dest[dest_len + i] = src[i]; dest[dest_len + i] = ''; return dest; } RETURN VALUE
The strcat() and strncat() functions return a pointer to the resulting string dest. CONFORMING TO
SVr4, 4.3BSD, C89, C99. SEE ALSO
bcopy(3), memccpy(3), memcpy(3), strcpy(3), strncpy(3), wcscat(3), wcsncat(3) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2008-06-13 STRCAT(3)
Man Page

7 More Discussions You Might Find Interesting

1. Programming

Linux C - how to open a pdf file with default reader

sorry if i repost this... hi.. i want to ask how to open pdf files using C in Linux in Windows, i just use this code: ShellExecute(GetDesktopWindow(), "open", "D:\\Folder\\File.pdf", NULL, NULL, SW_SHOWNORMAL); thanks for advance... (3 Replies)
Discussion started by: sunardo
3 Replies

2. Programming

segmentation fault while using popen

hi, i am trying to use popen to run a grep process and check if the pattern exists in the file that i am searching in. i am getting segmentation fault when i try to execute the following code char *cd; char flag; char hdr_flpsp; char hdr_flpsp2; FILE *fp; printf ("program starts");... (1 Reply)
Discussion started by: sais
1 Replies

3. UNIX for Dummies Questions & Answers

Simple Problems to Solve!

Hi, I'm pretty poor at using UNIX but I'm learning. Please help me with these simple problems! Much appreciated! 1. I've changed my shell from bash to csh but I prefer bash. How do I change back? I've tried using chsh -s but it's not working! 2. I'm trying to download TopCat. I've done... (2 Replies)
Discussion started by: SimonWhite
2 Replies

4. Programming

Now i can't get FD_ISSET to work

I have this server I am making but it ignores an if statement which I have posted below so i want to ask If I could post main.c which compiles without errors for me and see if anyone could tell me why the code below doesn't trigger my function. I want to ask first because some forums don't... (7 Replies)
Discussion started by: Errigour
7 Replies

5. Programming

System Calls using C w/BASH

Hello all, I'm attempting to write a basic application that appends an arbitrary list of txt files to one txt file. So, for example, if the application is run like so: appendFileToFile file1.txt file2.txt file3.txt the system command should, hopefully be, cat >> testfile.txt I'm... (4 Replies)
Discussion started by: whyte_rhyno
4 Replies

6. Programming

Concatenating Struct Value With Char In C

After googling everything I could, the best I could do with this is get the following warning with -Wall: gcc -Wall help.c -o help help.c: In function ‘findpid': help.c:29:25: warning: passing argument 2 of ‘strncat' from incompatible pointer type strncat( pro, &str, 60); ... (5 Replies)
Discussion started by: Azrael
5 Replies

7. Programming

Wildcard Pattern Matching In C

I've been having problems lately trying to do pattern matching in C while implementing wildcards. Take for instance the following code: #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <dirent.h> #include <string.h> ... (14 Replies)
Discussion started by: Azrael
14 Replies