|
exactly, that is what i want!!
|
|
|
|
|
I can think of two ways.
1: do it like: array[i][j*k]
all elements after j are of the second array.
2: In .NET you can create arrays of objects, an array is an object, so you could create an object array, put it in a object array ... you should be able to cast it back into an array, I think . Better would be that the object is a class containing not only an array, but also the size of it. Sort of a CArray class. (Overload for the basic types: CString, int, double ...)
good luck.
No hurries, no worries.
|
|
|
|
|
what's the difference between CString and string? which one will be better and easier to use?
so far i'm always sticking to string, as i learnt it that way. someone please enlighten me the advantages of CString over string.
|
|
|
|
|
CString is Microsoft's string class. It has an easier syntax to the methods that it exposes. I use string by default, and CString if I have to. I'm far more likely to use bstr_t ( converts between wide and narrow strings for you ) than CString.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
string was not thread safe until VS.NET I had to learn that the hard way. I believ with VS.NET when you copy one sring object to another it actually copies the entire contents of the string which can be a issue if you desire high performance. CString doesnot have the same problem. The CString with VS.NET is very impressive and very good. I recommend using it.
|
|
|
|
|
CStrings have thread affinity, which can be another reason to not use it.
suhredayan There is no spoon.
|
|
|
|
|
hello everybody!
I'm having trouble in changing a certain string.
if I have have that string:
strNum = 1234&567;
the thing is that I want to change the "&" sign to the "and"
so my string will be 1234and567.
can anyone help me with that somehow???
Thanks!
|
|
|
|
|
Does CString have a Replace function ? I don't think that std::string does. Either way, either you or a wrapper needs to allocate new memory and construct a new string ( char * ), because you want to replace one character with 3.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
you should tokenize the string with a delimiter of your choice, then append the tokens back into your string.
// code for tokenizing, taken from http://oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO-7.html[^]
void Tokenize(const string& str,
vector<string>& tokens,
const string& delimiters = " ")
{
// Skip delimiters at beginning.
string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
string::size_type pos = str.find_first_of(delimiters, lastPos);
while (string::npos != pos || string::npos != lastPos)
{
// Found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
pos = str.find_first_of(delimiters, lastPos);
}
}
|
|
|
|
|
Thanks!
understood!
|
|
|
|
|
have u tried strstr() of the string.h ?....itz used to find a string inside a srring!!!!!
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
now thats a useful info!
|
|
|
|
|
|
yeah I know, but I was looking for string, not CString.
but, I don't quite understand the difference between the two.
I know that CString is microsoft's string class, and it has more functionality, but what are the disadvantages of CString comparing to string?
|
|
|
|
|
|
i've checked the string class, and it also contains a replace member function, so essentially you can do the same thing that alok said for the CString class.
anyway here's more definitions for the string class: http://www.cppreference.com/cppstring/[^]
|
|
|
|
|
ng kok chuan wrote:
anyway here's more definitions for the string class: http://www.cppreference.com/cppstring/[^]
Looks Good Thanks
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hey need some help here
here's my code (partial)
class CMyClass : public CDialog
{
public:
HANDLE thread_handle;
DWORD thread_id;
UINT ThreadFunc(LPVOID data);
// other things
}
then
thread_handle = AfxBeginThread(ThreadFunc,
// (LPVOID)1,THREAD_PRIORITY_NORMAL, 0,0,NULL);
no the problem is i get this error
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
why am i getting that error.. also when i use the api method CreateThread it also produces an error saying that CreateThread cannot convert parameter 3 from unsigned long (void*) to unsigned long (__stdcall)(void*) or something like that... I really need to get this thread running for my program....
|
|
|
|
|
The thread function has to be declared static . This is because the compiler needs to determine its address, which won't be known until runtime otherwise.
|
|
|
|
|
I'm just writing to back up that other answer. It's true you do need to delcare static. Sometimes though, that can be a problem becuase you want to access member variables and functions back in CMyClass. Here's a good way to get what you want here, I think:
class CMyClass : public CDialog
{
public:
HANDLE thread_handle;
DWORD thread_id;
static UINT ThreadStartFunc(LPVOID data);
UINT ThreadFunc();
} and then...
thread_handle = AfxBeginThread(ThreadStartFunc, (LPVOID)this); then later:
UINT CMyClass::ThreadStartFunc(LPVOID data)
{
ASSERT(data != NULL);
return ((CMyClass*)data)->ThreadFunc();
}
UINT CMyClass::ThreadFunc()
{
return 0;
} I don't know if that helps at all.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Thanks.... it's working now... now i'm on to the final stage..
|
|
|
|
|
|
Joel Holdsworth wrote:
thread_handle = AfxBeginThread(ThreadStartFunc, (LPVOID)this);
Friend, you are breaking the cardinal rule of MFC, CWnd objects are not allowed to be passed between threads, it should only be used by the thread which created it. You will never be able to predict when the application bombs in your case. Please have a look into this link
q147578/[^]
suhredayan There is no spoon.
|
|
|
|
|
True... you're right! I wasn't thinking. I never create thyreads in window objects! I always have a dedicated class to administrate my worker or back-end or whatever.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Joel Holdsworth wrote:
I never create thyreads in window objects! I always have a dedicated class to administrate my worker or back-end or whatever.
Can't say anyhting without seing your administrator class
suhredayan There is no spoon.
|
|
|
|