I'm no VB programmer, since it's my personal opinion that VB is for idiots, so I don't know what mid() does.
Well this isn't very nice, is it? (although.. i prefer C/C++ myself)
Valmian
Junior Poster in Training
82 posts since Sep 2003
Reputation Points: 13
Solved Threads: 0
Did you declear the functions? May be there are these functions in reality since std::right would seem as if it thinks it is one of the library functions.. rename them to something like rightc() or smthn..
IIya
I'm assuming I create these as functions, but I get an error when calling them.
error C2665: 'std::right' : none of the 2 overloads can convert parameter 1 from type 'std::string'
Valmian
Junior Poster in Training
82 posts since Sep 2003
Reputation Points: 13
Solved Threads: 0
I think he was using strings all along..
It does strings, as in the character arrays. It doesn't do objects.
To get it to work, you have to do something like this:
char *string = "Hello. I am a string";
cout << right(string);
If there actually is a 'right()' function in there somewhere, I believe this will work:
::right(string);
Valmian
Junior Poster in Training
82 posts since Sep 2003
Reputation Points: 13
Solved Threads: 0
#include <iostream>
#include <stdlib.h>
#include <string>
#define ONE " via c++ string at() (worx only on 1 char): "
#define MORE " via c++ string substr() (worx on more chars): "
using namespace std;
int main(void)
{
string test;
do
{
cout << "Enter the teststring (6 chars minimum): ";
cin >> test;
}
while (test.size() < 6);
/* u could actually use more chars with substr() method than just one
* for example u could replace the test.substr(0, 1) with test.substr(0, 2)
* to get 2 chars
*/
cout << "\n\tleft()" << MORE << test.substr(0, 1) << "\n";
cout << "\tleft()" << ONE << test.at(0) << "\n\n";
cout << "\tright()" << MORE << test.substr(test.size() - 1, 1) << "\n";
cout << "\tright()" << ONE << test.at(test.size() - 1) << "\n\n";
/* here i extracted the 5th char, remember counting in c / c++ begins at 0, not at 1 */
cout << "\tmid()" << MORE << test.substr(4, 1) << "\n";
cout << "\tmid()" << ONE << test.at(4) << "\n\n";
system("PAUSE");
return 0;
}
this is actually some source who should illustrate you the use of the c++ string class (which is very handy) in order to simulate the vb functions u asked for, so u dont need your own functions for it, since all is already in c++ :cheesy:
r0ckbaer
Junior Poster in Training
55 posts since Dec 2003
Reputation Points: 13
Solved Threads: 6
Please don't bump ancient threads. Locked.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401