|
This version should handle any number (int, long, etc.):
template <typename T>
std::string format(T t)
{
std::stringstream strm;
strm.imbue(std::locale(""));
strm << t;
return strm.str();
}
Last modified: 11mins after originally posted --
Kicking squealing Gucci little piggy.
|
|
|
|
|
|
Exactly how does this add commas to the number?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I see he gets file size so I guess its better he uses from this function (for comma CString::Format )
|
|
|
|
|
Use GetNumberFormat() to format a number with commas (or whatever you use in your locale).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I am using Visual studio 2005 (VC.Net). I am getting a very strange error in my application when i am calling managed code function ie. When I am loading XML file through load function with System::XML::XmlDataDocument object variable. The error message is
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'C:\TestApp.exe'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79f9432a, on thread 0x3d4. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
Please kindly help me.
Regards,
KN Rao
knarasimharao
|
|
|
|
|
It seems its Managed C++,right?
|
|
|
|
|
yes it's a managed C++
knarasimharao
|
|
|
|
|
I think if you ask this question in CLI/C++ forum you can get your answer
|
|
|
|
|
Hello all,
i have very specific question regarding winsock
"In a network of PC's, i want to find the ip addresses of all the nodes that are running my custom made windows service"
How to achieve this. Service is made in C++ using win32 api's and i m using winsock for all networking purposes
thanks
kunal s patel
|
|
|
|
|
Hi,
I dont know what is your windows service doing. But I have an idea.
You can take care of this.
The idea is that your windows service program should populate a broadcast message in your network for every time intervals. In that broadcast message you can specify your default message that includes ip address, etc.,
In your winsock program , you could receive that default message. The default message might have an IP address of the host machine.
Using this you can achive your way.
|
|
|
|
|
Thanks for the fast reply. Can any one please suggest me how to broadcast a packet in network. What care should i take in sender side and receiver side. A sample code would be of great help
thanks
kunal s patel
|
|
|
|
|
I want to control no new derivations from base class . How can i achieve it ?
I want to control to create atleast one instance to my class, then how can i achieve it ?
just i faced these questions in an Interview.
please guide me regarding this.
|
|
|
|
|
Krishnatv wrote: I want to control no new derivations from base class . How can i achieve it ?
Make the constructor of the base class private. If you inherits a class from this base class, you'll get a compile error saying that it cannot access the constructor of the base class.
Krishnatv wrote: I want to control to create atleast one instance to my class, then how can i achieve it ?
Are you sure your question is correct ? So, you want to have at least one instance of your class ? You can simply declare a static instance in the cpp file of your class but I doubt this is the answer you are looking for.
|
|
|
|
|
Are you sure your question is correct ? So, you want to have at least one instance of your class ? You can simply declare a static instance in the cpp file of your class but I doubt this is the answer you are looking for.
I dont want to allow at least one object also.( No Objects)
|
|
|
|
|
Krishnatv wrote: I want to control to create atleast one instance to my class, then how can i achieve it ?
You just want one instance of a class or more than one.(You are already allowed to create as many instances of your class as you wish)
If you say that you only want to let the user create a single instance of your class then you should use a static variable in your class. Increment that variable in the constructor if first object is being created. Now when second object would be created check for the value of the static variable to be greater than 1(or something that you work out), if affirmative just return from the contructor. This won't let the user create a second instance of your class.
You can also search for other methods here on CP for the SingletonClass.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I dont want to allow atleast one instance also.
|
|
|
|
|
Krishnatv wrote: I dont want to allow atleast one instance also.
1) So what? You can check for the value of the static variable to be zero and return from the constructor.
2) If your question pertains to objects you can also create an abstract class.You can't create an object of the abstract class. To create a abstract class just add one pure virtual function to your class definition.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thank u so much Anshuman For ur Good clarification.
Just Now Iam understanding why C++ is this much tricky.
|
|
|
|
|
Does anybody have any experience with the squirrel scripting library? I have already posted my question on their forums but they look a little inactive.
I'm trying to pass a struct by reference to a script but I am unable to find any example of how to do this.
|
|
|
|
|
Dear All,
I need to know about that stack segment, code segments, data segment and heap.
Where can i get a good article ?
If you know kindly let me know ?
|
|
|
|
|
Sakthiu wrote: stack segment, code segments, data segment and heap.
See Here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Sakthiu wrote: Where can i get a good article ?
Have you tried Googling for one?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
I have inserted class through MFC Class Wizard ->Import library ->WartzODLCOM.dll.
Class = _DBAccess
Base Class = ColeDispatchDriver
And i want to call function in wartxodlcom.cpp.
How to do that.i am trying to create instance by _DBAccess dbaccess it is giving error.Why.
|
|
|
|