|
how to convent variables from "String* " to "unsigned char *"?
&
how to convent variables from "unsigned char * " to "String *"?
Thank you very much!
|
|
|
|
|
Did you take a look at the Marshal.StringToPtrAuto and related methods?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
thanks for your prompting,
:(but i can't find the Marshal.StringToPtrAuto In neither Google Search or CP Search,
so can you tell me how to find it ?
Thank you very much.;)
|
|
|
|
|
Hello everyone!
OK, I just got into C++, and I need help with replacing text within a string... I'm looking for something like:
strreplace(charArray, oldValue, newValue);
The replace() function in the string class is hard to understand... Can anybody tell me what to do? Thanks!
BTW: The program I'm making is gonna be awesome when it's done!
And I'm on Borland's compiler. :P
Sulfurik K. Nosferathus (Darth_Sulfur)
www.SulfurMidis.com
www.SulfurSoft.tk
http://www.BeepXtreme.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 17:58 Monday 5th September, 2005
|
|
|
|
|
Darth_Sulfur wrote:
he replace() function in the string class is hard to understand... Can anybody tell me what to do?
string& replace(size_type pos, size_type n, const string& str);
Delete a substring from the current string, and replace it with another string.
string str14 = "abcdefghi";
string str15 = "XYZ";
str14.replace (4,2,str15);
cout << str14 << endl; // "abcdXYZghi"
I got that from google. It's pretty clear, you need to know the location and length of the string you want to replace. You could easily write a helper function that finds these things, and does the replace in the manner you're hoping.
Good luck !!
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hard to understand ?
hum, let's see what the MSDN[^] tells us...
as you can see, there are 10 overloads of the function. choose the you you find the best for what you need, then, pass it the parameters it's waiting for (be careful of the type so...
the overload christian show you is the first one :
basic_string& replace(
size_type _Pos1,
size_type _Num1,
const value_type* _Ptr
);
_Pos1
The index of the operand string at which the replacement begins.
_Num1
The maximum number of characters to be replaced in the operand string.
_Ptr
The C-string that is to be a source of characters for the operand string.
i hope you understand better the doc...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Darth_Sulfur wrote:
C# is SOOOOOOOOOO much easier than C++!
nop, C# is better than Managed C++... here is the difference ;P
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
I have a C# project that needs to use a C++ SDK, so I'm trying to write a MC++ dll to act between them. At first, this was fine, but the problem is, the SDK defines a number of function pointers for callbacks. The objects I pass through complain that they are __gc type instead of type, and the pointers themselves complain that they are not __stdcall, which I assume means that the .NET stuff has it's own calling convention. However, I'm not that knowledgable when it comes to dlls, and I sure have never used MC++ before. I tried putting __nogc at the head of the class, that fixed all my errors, but gave me a new one, telling me I can't do that. What's the best way for me to proceed here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
...For those of you who are interested, this inquiry reaches a dramatic conclusion over at the Microsoft Technical Forums. I'm just SO HAPPY that I didn't make a TOTAL ASS out of myself, by attempting to offer some advice about something,...WELL, OK, BYE,...
cgraus[^]
And, More Analysis[^]
-- modified at 19:29 Tuesday 13th September, 2005
|
|
|
|
|
|
There is a AT protocal hardware, on which I want to build a http channel.
How to design?
Thanks!
|
|
|
|
|
#include <iostream>
using namespace std;
class A
{
int i;
public:
A(int ii):i(ii){}
int operator ++()
{
return ++i;
}
int operator ++(int)
{
int ntemp;
ntemp = i;
i++;
return ntemp;
}
int geti(){return i;}
};
int main()
{
A a(2);
cout << ++a << endl << a.geti() << endl;
}
The operator "<<" is evaluated from left to right how can a.geti() gets called first?
|
|
|
|
|
I don't understand the question (you could have placed some punctuation... )
well, if i am not on what you mean, please reformulate.
you're asking for why geti() is called before ++a ?
it isn't...
otherwise, i missed your point.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
you're asking for why geti() is called before ++a ?
it isn't...
I'm under VC++ 6.0 and saw with my own bear eye geti() is called before ++a.
You can make those member function involved announce themselves, then you'll see the calling sequence!
|
|
|
|
|
The order of evaluation is for the << operator only, not for the operands of the << operator. The left to right associativity of << means that your statement will look like
((((cout << ++a) << endl) << a.geti()) << endl);
That is, cout << ++a will be calculated first, then the result of that will be the LHS and endl will the RHS next time and so on. It doesn't mean that the compiler needs to evaluate ++a before a.geti(). The compiler usually will evaluate ++a and a.geti() (in any order it wishes to, IIRC) before starting to execute the << operator.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi there.
I am working on a project wich requires me to use matrices and do some computations on them. So I downloaded the LINPACK linear algebra library from
http://www.csit.fsu.edu/~burkardt/cpp_src/linpack/linpack.html
The library is very nice, offering a huge collection of very usefull matrix arithmetic.
I downloaded the source for the library which consisted of 2 .h files and 2 .c files. And when I try to compile the c files, using Visual Studio C++ 2003, I get two build errors:
linpack.c
c:\Documents Of I\UP\Year5 Semester2\EPR400\My Programming\TestMatrix\linpack.C(5668) : fatal error C1010: unexpected end of file while looking for precompiled header directive
blas1.c
c:\Documents Of I\UP\Year5 Semester2\EPR400\My Programming\TestMatrix\blas1.C(4532) : fatal error C1010: unexpected end of file while looking for precompiled header directive
So I need help to get the source code to compile on VS C++ 2003. I think I need to change settings for the precompiled headers section of the project properties but I dont have a clue what it all means.
Please help!
Thanks!
Ben
|
|
|
|
|
add to your c files #include "stdafx.h" if u are using then into a visual c++ project with precompiled header project option
NG
|
|
|
|
|
Or you could just edit your project properties to not include precompiled headers.
|
|
|
|
|
Hi.
Including the "stdafx.h" file in all the source files worked.
I couldn't turn of the Use Precompiled Headers option because the other source files in my project did indeed already include "stadafx.h".
Thanx for the help guys!!
|
|
|
|
|
I'm having trouble trying to do one on the implementation files of my project. can you plz help... i will attach the appropriate header file/s and .cpp files which I have completed, yet however that is one .cpp which is partially completed, can you really help with the definition of the member functions. The partially completed file is called EmployeeDatabase_template[1].cpp. i included the source code below for you to look at. plz help with definition of these member functions
#include "EmployeeDatabase.h"
#include
using namespace std;
EmployeeDatabase::EmployeeDatabase()
{ // Complete code.
people = 0; // The database is a vector of Persons.
size = 0; // The number of Persons in the database.
}
void EmployeeDatabase::getEids(vector &ids)
{ // Complete code.
}
string EmployeeDatabase::getName(int employeeID)
{// Complete code.
}
double EmployeeDatabase::getShoeSize(int employeeID)
{// Complete code.
}
void EmployeeDatabase::makePerson(string employeeName, int employeeID, double employeeShoeSize)
{//complete code.
}
int EmployeeDatabase::getSize()
{// Complete code.
return size;
}
here is the appropriate specification files(header files).
this is EmployeeDatabase.h
// A EmployeeDatabase consists of a vector of Persons;
// methods are supplied to retrieve all the employee IDs and
// to query the database for employee names and shoesizes using
// the corresponding employee id.
#include "Person.h"
#include
using namespace std;
#ifndef EmployeeDatabase_H
#define EmployeeDatabase_H
class EmployeeDatabase{
public:
EmployeeDatabase();
// Constructor:
// Makes an instance of an EmployeeDatabase containing no data.
void getEids(vector & ids);
// Returns a vector of all the employee ids in the vector people.
string getName(int employeeID);
// Returns the name of the Person with eid equal to employeeID.
double getShoeSize(int employeeID);
// Returns the shoesize of the Person with eid equal to employeeID.
void makePerson(string employeeName, int employeeID, double employeeShoeSize);
// Creates a new instance of Person using the input data
// and adds it to the vector people.
int getSize();
// Returns the number of Persons stored.
private:
vector people; // The database is a vector of Persons.
int size; // The number of Persons in the database.
};
#endif //EmployeeDatabase_H
This is Person.h
// A Person consists of the name, the employee ID and the shoe size.
// Methods are supplied to retrieve each of the three data items.
using namespace std;
#include
#ifndef Person_H
#define Person_H
class Person{
public:
Person(); // Default constructor.
Person(string personName, int personId, double personShoeSize);
// Constructor:
// Makes an instance of a person with the
// given data.
string getName();
// Returns the name of the Person.
int getEid();
// Returns the employer ID of the Person.
double getShoeSize();
// Returns the shoesize of the Person.
private:
string name; // The employee's name.
int eid; // The employee's ID.
double shoeSize; // The employee's shoesize.
};
#endif
PLZ WITH THE FIRST BIT OF CODE THE OTHER TWO ARE THE HEADER FILES. I JUST CANT FIGURE OUT HOW TO DEFINE SOME OF THEM.
|
|
|
|
|
hi,
i have one request if you want some help :
please edit.Modify your message and put the codes into <pre></pre> tags for us to see the indentations, and the blocs of code correctly. you could separate the files using several tag blocs.
one more thing :
use the < and > buttons at the bottom of the edit box to let us see the template parameters... (we do not see the vectors and so...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
ok. no worries, thanks for the swift reply.
I'm having trouble trying to do one on the implementation files of my project. can you plz help... i will attach the appropriate header file/s and .cpp files which I have completed, yet however that is one .cpp which is partially completed, can you really help with the definition of the member functions. The partially completed file is called EmployeeDatabase_template.cpp. i included the source code below for you to look at. plz help with definition of these member functions
<pre>
#include "EmployeeDatabase.h"
#include <vector>
using namespace std;
EmployeeDatabase::EmployeeDatabase()
{ // Complete code.
size = 0;
}
void EmployeeDatabase::getEids(vector <int>&ids)
{ // Complete code.
}
string EmployeeDatabase::getName(int employeeID)
{// Complete code.
}
double EmployeeDatabase::getShoeSize(int employeeID)
{// Complete code.
}
void EmployeeDatabase::makePerson(string employeeName, int employeeID, double employeeShoeSize)
{//complete code.
}
int EmployeeDatabase::getSize()
{// Complete code.
return size;
}
</pre>
here is the appropriate specification files(header files).
this is EmployeeDatabase.h
<pre>
// A EmployeeDatabase consists of a vector of Persons;
// methods are supplied to retrieve all the employee IDs and
// to query the database for employee names and shoesizes using
// the corresponding employee id.
#include "Person.h"
#include <vector>
using namespace std;
#ifndef EmployeeDatabase_H
#define EmployeeDatabase_H
class EmployeeDatabase{
public:
EmployeeDatabase();
// Constructor:
// Makes an instance of an EmployeeDatabase containing no data.
void getEids(vector <int>& ids);
// Returns a vector of all the employee ids in the vector people.
string getName(int employeeID);
// Returns the name of the Person with eid equal to employeeID.
double getShoeSize(int employeeID);
// Returns the shoesize of the Person with eid equal to employeeID.
void makePerson(string employeeName, int employeeID, double employeeShoeSize);
// Creates a new instance of Person using the input data
// and adds it to the vector people.
int getSize();
// Returns the number of Persons stored.
private:
// The database is vector of Persons.
vector <Person> people;
int size; // The number of Persons in the database.
};
#endif //EmployeeDatabase_H
</pre>
This is Person.h
<pre>
// A Person consists of the name, the employee ID and the shoe size.
// Methods are supplied to retrieve each of the three data items.
using namespace std;
#include<string>
#ifndef Person_H
#define Person_H
class Person{
public:
Person(); // Default constructor.
Person(string personName, int personId, double personShoeSize);
// Constructor:
// Makes an instance of a person with the
// given data.
string getName();
// Returns the name of the Person.
int getEid();
// Returns the employer ID of the Person.
double getShoeSize();
// Returns the shoesize of the Person.
private:
string name; // The employee's name.
int eid; // The employee's ID.
double shoeSize; // The employee's shoesize.
};
#endif
</pre>
PLZ CAN YOU HELP ME WITH THE FIRST BIT OF CODE THE OTHER TWO ARE THE HEADER FILES. I JUST CANT FIGURE OUT HOW TO DEFINE SOME OF THE MEMBER FUNCTIONS.
-- modified at 23:40 Monday 5th September, 2005
|
|
|
|
|
class A
{
int i;
public:
A(int ii):i(ii){}
int operator ++()
{
return ++i;
}
int operator ++(int)
{
int ntemp;
ntemp = i;
++i;
return ntemp;
}
int geti(){return i;}
};
int main()
{
A a(2);
cout << a++ << endl
<< a.geti() << endl;
getchar();
}
Why the result is "2, 2" instead of "2, 3". a++ seems doesn't operate on A::i?
|
|
|
|