How to get substrings from char pointer array?

hi i want subString from char array...how ?

char*p=12345678;

now i just wanted 1234

String st="1234"

now i just wanted 1234

As a string or a String?

As a string:

   char sub[5];
   strncpy(sub, p, 4);

As a String:

   String wasteOfResources = String(p).substring(0, 4);

For the first example, one needs to add the terminating nul character.

char sub[5];
strncpy(sub, p, 4);
sub[4] = '\0';

sterretje:
For the first example, one needs to add the terminating nul character.

char sub[5];

strncpy(sub, p, 4);
sub[4] = '\0';

wow it work for me...thanks a lot

Users/john/Documents/Arduino/sketch_aug16a/sketch_aug16a.ino:8:11: warning: invalid conversion from 'long int' to 'char*' [-fpermissive]
 char *p = 12345678;
           ^

You should be concerned when you get compiler warnings. There is a major difference between a numeric constant and a string constant. You want:

 const char *p = "12345678";