Hi everybody,
I am trying to make the real substr function in c++ which its a member of String Class.
Here what I have done:
void substr(char x[], int n, int n2){
char *p;
p = x;
for(int i=0; i<=n2; i++)
*(p+i) = *(p+i+n);
*(p+n2) = '\0';
// I can use this
cout << x << endl;
}
An the Main is:
int main(){
char x[] = "It should work.";
substr(x,3,6);
return 0;
}
The problem is that I can't return the array of char[]. BTW, I don't want to use anything use <string> library.
can any one figure the function to return char[] so I can use this in main:
char y[] = substr(x,3,5)
Regards,