Logo

Programming-Idioms

History of Idiom 46 > diff from v3 to v4

Edit summary for version 4 by :

Version 3

2015-08-19, 14:20:02

Version 4

2015-08-20, 10:23:12

Idiom #46 Extract beginning of string (prefix)

Create string t consisting in the 5 first characters of string s.

Idiom #46 Extract beginning of string (prefix)

Create string t consisting in the 5 first characters of string s.

Imports
#include <stdlib.h>
#include <string.h>
Code
char *t=malloc(6*sizeof(char));
strncpy(t,s,5);