Thursday, 12 January 2012

Strncat Functions

#include <stdio.h>
char *strncat(char *dest, const char *src, int n); 
The strncat function concatenates or appends first n characters from src to dest. All characters from src are copied including the terminating null character.
Return Value
The strncat function returns dest.
#include <stdio.h>
int main() 
  char string1[20];
  char string2[20];
  strcpy(string1, "Hello");
  strcpy(string2, "Hellooo");
  printf("Returned String : %s\n", strncat( string1, string2, 4 ));
  printf("Concatenated String : %s\n", string1 );
  return 0;
It will proiduce following result:
Returned String : HelloHell
Concatenated String : HelloHell

No comments:

Post a Comment

host gator coupon