|
Sorry for the delayed response,
I can't access to it in debug mode
But there is something make me confused that when i give properties of allowing edit the value false (not editable) this event (PushChar) is triggered !!!!!!!!
|
|
|
|
|
Hi everyone,
I'm currently using a vector of vectors (which includes a pair of objects), I declare it as:
vector< pair< vector< long double >,string > > vec;
the problem is, I really need a "triple" which I know doesn't exist, so does anyone know how I could add an additional variable such as an additional vector of integers into the mix, and if so, how I'd load and access the data?
I currently use the following to load data:
vec.push_back(pair< vector< long double >,string > (row_temp, header));
where row_temp is a vector of "long doubles" and "header" is a string.
and I use the following to access the data:
newvec[zz].first[yy]
newvec[zz].second.data()
where zz and yy are just integer variables based on the loop that I'm currently in.
The reason that I'm needed to treat so many items as a single object is that I perform some sorting and "unique" routines on the vectors in the end.
Thanks in advance!
|
|
|
|
|
create a 'triple' class to replace the 'pair'... ?
template <class T1, class T2, class T3> triple
{
triple (const & T1 a, const & T2 b, const & T2 c)
{
first = a;
second = b;
third = c;
}
.. etc..
T1 first;
T2 second;
T3 third;
};
?
|
|
|
|
|
Thanks for the quick reply!
Where do I need to put this template class (I'm using visual studio c++)?
Thanks!
|
|
|
|
|
put it in a new .H file and #include it where you need to use it.
if i was going to do this, i'd find the source for std::pair, copy it, then modify it to add the 'third' member . that way, i'd be sure to get all the c-tors and operators that i'd need, without having to add them one-by-one as the compiler complains.
you can probably find some std::pair implementations on-line, otherwise search your Visual Studio include files for "struct pair", to find the one that ships with your version of VC++.
|
|
|
|
|
|
b-rad311 wrote: the problem is, I really need a "triple" which I know doesn't exist
If you have a recent MS compiler, i would suggest using the tuple[^] class. Very easy to use and does exactly what you want.
|
|
|
|
|
Hello
I need the c code to perform the following task "Given an IP address, check for validity of IP address".
Suppose the ip address is 172.16.10.61. So it is a valid address. Here to check it by taking separately each byte and check the range( 0-255) ( for exapmle using strtok(ipaddress, ".") ).I work in a fedora Linux 11. Instead of using the strtok on ip address string any direct library function is there?
Thanking you,
Krishna
modified on Thursday, March 25, 2010 8:51 AM
|
|
|
|
|
Let Me Google That For You.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Google gives the solution in php program, but I want in c-code
|
|
|
|
|
Damn you google! :shakes fist:
|
|
|
|
|
krish_kumar wrote: but I want in c-code...
Which is exactly what was provided to you.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Google's first hit: "How to validate IP address in C"...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I would like to know if there are some good tools available to get the reverse engineered diagrams given
a set of files under a legacy project that needs to be reused and refactored.
It would be great if someone categorizes into Freeware open sources ones and that which comes with a cost.
|
|
|
|
|
Can't beat IDA Pro[^] with the decompiler plugin. screen shot[^]
There's a demo available. The disassembler and the decompiler pair will set you back about $3800 USD.
|
|
|
|
|
error LNK2005...already defined
While building my code in VS2008 I am getting a build error: error LNK2005...already defined in ....
1>Linking...
1>Main.obj : error LNK2005: "unsigned char * X1" (?X1@@3PAEA) already defined in BC.obj
1>Main.obj : error LNK2005: "char * X2" (?X2@@3PADA) already defined in BC.obj
1>Rs.obj : error LNK2005: "unsigned char * X1" (?X1@@3PAEA) already defined in BC.obj
1>Rs.obj : error LNK2005: "char * X2" (?X2@@3PADA) already defined in BC.obj
In my project I have three .h files:
1) Common_Definitions.h
unsigned char X1[16];
char X2[4];
struct xyz
{
UINT32 X3;
unsigned int X4[4];
long X5;
int X6;
int X7;
};
2) BC.h
3) RS.h
I have three .cpp files
1) Main.cpp
2) BC.cpp
3) RS.cpp
In Common_Definitions.h I have definitions/declarations which I want to be available in entire project, While BC.h and RS.h has corncenred variables.
I have included Common_Definitions.h in BC.h and RS.h.
#ifndef Common_Definitions_h
#define Common_Definitions_h
#include "Common_Definitions.h"
#endif
I have included BC.h and RS.h in their corresponding .cpp files.
I have included BC.h and RS.h also in Main.cpp
Now while building I get the linker error LNK2005.
How to resolve it?
Earlier when I had included Common_Definitions.h in BC.h and RS.h directly without ifndef.
#include "Common_Definitions.h"
then it was giving compilation error:
1>d:\...\common_deFINITIONS.h(18) : error C2086: 'unsigned char X1[16]' : redefinition
1> d:\...\common_deFINITIONS.h(18) : see declaration of 'X1'
1>d:\...\common_deFINITIONS.h(19) : error C2086: 'char X2[4]' : redefinition
1> d:\...\common_deFINITIONS.h(19) : see declaration of 'X2'
1>dd:\...\common_deFINITIONS.h(22) : error C2011: 'XYZ' : 'struct' type redefinition
1> d:\...\common_deFINITIONS.h(22) : see declaration of 'XYZ'
So to resolve that I have included Common_Definitions.h in BC.h and RS.h using ifndef.
#ifndef Common_Definitions_h
#define Common_Definitions_h
#include "Common_Definitions.h"
#endif
But this is leading to linker error.
Please let me know how to resolve this compiler and linker issue?
|
|
|
|
|
You should try to instance any objects
in the *.cpp file(s) only...
When you will want to share any defined variables by other files -
just use "extern" definition:
...
char* pchTest("test");
...
extern char* pchTest;
...
virtual void BeHappy() = 0;
|
|
|
|
|
Thanks Eugen for the reply.
In my case I have one var X1 in a .h file.
I want to use this X1 in three other .cpp files, then how should I declare and define it?
|
|
|
|
|
It could be made as following :
...
...
...
unsigned char X1[16];
...
...
extern unsigned char X1[16];
...
...
extern unsigned char X1[16];
...
(The answer would be different
when you would like to share a type (not an instance),
but the X1 is an instance (not a type)... )
virtual void BeHappy() = 0;
|
|
|
|
|
ok thanks
this clarifies it all.
Also presently I did not declare the variables as extern in the header/cpp files.
But I included the declaration of header files as:
Declaration for common_definitions.h, bc.h and rs.h is now changed as:
#ifndef bc_h
#defibe bc_h
-----declaration of bc.h
#endif
#ifndef rs_h
#define rs_h
-----declaration of rs.h
#endif
This also resolved the issue.
|
|
|
|
|
You are welcome !
PS. you could also use:
#pragma once
...
PPS. if you need an own instance in your *.cpp you could also use:
#pragma once
...
typedef struct s {
int m_iVar1;
int m_iVar2;
} myS;
typedef UCHAR myBuffer[16];
...
...and then :
...
#include "CommonSettings.h"
...
myBuffer ownBuffer;
...
...
#include "CommonSettings.h"
...
myS ownS = {0};
virtual void BeHappy() = 0;
|
|
|
|
|
|
Hi i am using VC7 and i want to connect mysql 5.1 through odbc driver mysql 5.0.
i have conncect database by cdatabase class . after successfuly open the database we called open method of Crecordset but it give exception.
CRecordSet rs(m_db);//
rs.open(CRecordSet::Dynaset,"Select * form Tablename",CRecordSet::none);
above line guve exception aboiut dynaset. we are unable to call open function of Crecordset.
but CRecordSet::snapshot work fine.
|
|
|
|
|
Please check CDBException::m_strError : it should give you useful info about the problem.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i got proper exception in case of "Creordset::dynaset".
How can call open method of Crecordset with Creordset::dynaset to fetch record from Mysql
|
|
|
|