August 14th, 2003, 05:17 PM
i know in java we can catch some characters inside an array (using substring), can we do it too in C?
ex: array="blueberry";/*can we take out the "blue"?*/
August 15th, 2003, 02:39 AM
u may want to chk out string.h... or if u are in linux/unix, chk out its man pages....
loads of char* manipulation functions there. (in my opinion more than what java offers...,but thats just my own humble opinion)
August 17th, 2003, 11:23 AM
You can't take it out, you can copy part of the values in memory you want to keep somewhere else, or access the section you want with another pointer etc...
char *str = "Blueberry";
printf("str = %s\n", str);
I would imagine most people would think the second is more correct, you aren't hinting that the allocated memory for the character array should be partly forgotten about.
char str = "Blueberry";
ptr = str+4;
printf("ptr = %s\n", ptr);