I need implement a MID function like this:
Mid(string,START,FINISH)
Thanks
Printable View
I need implement a MID function like this:
Mid(string,START,FINISH)
Thanks
use strncpy
General idea:
Code:char *mid( char *strDest, const char *strSrc,
size_t count,size_t offset ){
strncpy(strDest, *(strSrc+offset), count);
return strDest;
}
I think the extra abstraction layer is unnessesary overhead
It is.
But he asked how to do it. So I did it. He's a VB programmer trying to learn C, obviously.
yeah obviously, but i think we'd do him a favour suggest to learn the language instead.
Thanks for the example.
Yes, i am a Vb programmer, i try learn VC, is very versatile, but very hard to learn too. :p
Important lesson: VC and VC++ are not languages. VC++ is an IDE. C and C++ are languages.
As for mid: it's called substr in the string class.
Output:Code:#include <string>
#include <iostream>
using namespace std;
int main()
{
string mystring("Hello, there!");
cout << mystring.substr(3, 4) << endl;
return 0;
}
lo,