1,247 Posted Topics

Member Avatar for dbgarlisch

>> // will not work - Save() wants an IStream!!! >> Gdiplus :: status hr = image.Save (pFile, &encoderClsid); [code=cplusplus]// ...... IStream* pstm ; assert( CreateStreamOnHGlobal( 0, TRUE, &pstm ) >= 0 ) ; Gdiplus::Status hr = image.Save( pstm, &encoderClsid ) ; STATSTG stat ; assert( pstm->Stat( &stat, STATFLAG_NONAME ) …

Member Avatar for dbgarlisch
1
219
Member Avatar for tonyaim83

>> ... depending on the value of variable "var"at runtime. Also i know it can be done using template ... an option would be to use run-time polymorphism. [code]class base { virtual ~base() = 0 {} }; class Class1 : public base {} ; class class2 : public base {} …

Member Avatar for vijayan121
0
174
Member Avatar for m_meena
Member Avatar for vijayan121
0
113
Member Avatar for iaindb

>> and then for the macro call I could say ... and the test would be done inline, >> but I can't do that with a function, because the arguement is evaluated before it's passed: use a function object (or a pointer to a function; not as flexible or efficient) …

Member Avatar for iamthwee
1
163
Member Avatar for emin3m

add this too. you have overloaded operator new, but not overloaded operator delete. so [inlinecode]delete whatever[/inlinecode] will call the wrong operator delete; the results will not be pretty.

Member Avatar for vijayan121
0
211
Member Avatar for toolmanx

you could use the following compiler switches. [B]/C[/B] preserve comments during preprocessing. [B]/E[/B] copy preprocessor output to standard output (with #line) [B]/EP[/B] copy preprocessor output to standard output (without #line) [B]/P[/B] write preprocessor output to a file. To set this programmatically, use the [B]VCCLCompilerTool[/B] class. [B]VCCLCompilerTool::GeneratePreprocessedFile[/B] property provides the same …

Member Avatar for vijayan121
0
127
Member Avatar for eranga262154

>> .. really mad. It,s not displays as a binary code, I mean bunch of zeros and ones. if all you want to do is display the contents of a file as a sequence of bits (i presume that is what you mean by bunch of zeros and ones), [code=cplusplus]#include …

Member Avatar for eranga262154
0
323
Member Avatar for m_meena

for merely notifying another process that some event has occurred, you could use an event object. [URL]http://msdn2.microsoft.com/en-us/library/ms682655.aspx[/URL] [URL]http://www.codeproject.com/csharp/interopevents.asp[/URL] to also pass additional information, you would need to use an ipc mechanism. [URL]http://msdn2.microsoft.com/en-us/library/aa365574.aspx[/URL]

Member Avatar for vijayan121
0
85
Member Avatar for Ricle

[url]http://www.linuxhacker.at/socketxx[/url] [url]http://www.boost.org/doc/html/thread.html[/url]

Member Avatar for vijayan121
0
65
Member Avatar for hapiscrap

create an Xcode C++ tool project. [url]http://www.meandmark.com/xcodeintro.pdf[/url]

Member Avatar for vijayan121
0
148
Member Avatar for jaepi

>> what is the corresponding standard lib function of Win32's WideCharToMultiByte()? there are two options available; use the ctype<> facet or the codecvt<> facet. the following example uses ctype<> for conversion. [code=cplusplus]#include <locale> #include <iostream> #include <string> #include <sstream> using namespace std ; wstring widen( const string& str, const locale& …

Member Avatar for jaepi
0
145
Member Avatar for aslamkhan24
Member Avatar for vijayan121
0
60
Member Avatar for vijayan121

there seems to be nothing much happening in the c++ forum today. so here is something to chew on for programmers who are relatively new to templates: c++ can also be used as a metalanguage. [code=cplusplus]#include <iostream> using namespace std ; // compile-time computation of fibonacci numbers template < int …

Member Avatar for Bench
1
451
Member Avatar for cathy01

for simple round-robin scheduling, add the jobs to the back of a simple queue (use a std::queue for this). to schedule a job, pick the one at the front of the queue. if a job blocks (goes into a wait state) or its time-slice is over, put it back (at …

Member Avatar for vijayan121
0
106
Member Avatar for venomlash

>> I took a course in JAVA and learned about exceptions...I'm not sure how to throw and catch in C++. the fundamental difference is the use of the 'resource acquisition is initialization' technique in resource management. the c++ philosophy is a. error handling code must be clearly seperate from normal …

Member Avatar for vijayan121
0
158
Member Avatar for ajay.sontakke

and here are some books. 1. Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides (Addison-Wesley Professional) 2. Design Patterns Explained: A New Perspective on Object-Oriented Design (2nd Edition) by Alan Shalloway, James Trott (Addison-Wesley Professional) 3. Refactoring: Improving the Design of Existing …

Member Avatar for vijayan121
0
209
Member Avatar for Tight_Coder_Ex

you would be better off using icc for processor-specific optimizations. even without processor-specific optimizations, icc generates better optimized code than vc++ 8; and it blows gcc away. [URL]http://www.intel.com/cd/software/products/asmo-na/eng/276615.htm[/URL]

Member Avatar for WaltP
0
143
Member Avatar for n.aggel

using boost.spirit may be much easier: [URL]http://www.boost.org/libs/spirit/doc/quick_start.html[/URL] [code=cpp]#include <boost/spirit/core.hpp> #include <iostream> #include <string> #include <vector> #include <algorithm> #include <boost/assign.hpp> using namespace std ; using namespace boost ; using namespace boost::spirit ; using namespace boost::assign ; struct parse_it { void operator() ( const string& str ) const { vector<string> tokens ; …

Member Avatar for n.aggel
0
191
Member Avatar for Ken JS

here is a safer version which performs sanity checks [code=cplusplus]#include <sstream> #include <limits> #include <cassert> // returns 0 on overflow template< typename T > inline T join( T a, T b ) { typedef std::numeric_limits<T> limits_type ; assert( limits_type::is_specialized && limits_type::is_integer ) ; assert( !limits_type::is_signed || ( b>=0 ) ) …

Member Avatar for Ken JS
0
135
Member Avatar for aruna

main is a function written by the user, but it is special in several ways. as per ISO/IEC 14882(E): 3.6.1-1a program shall contain a global function called main, which is the designated start of the program. ... 3.6.1-2 an implementation shall not predefine the main function. this function shall not …

Member Avatar for vijayan121
0
86
Member Avatar for Arctic wolf

[CODE]printf((char *)&num);[/CODE] is clearly an error; you are casting a double* to a char* (which is incorrect). unpleasant consequences would be the norm if you do such things. in C, to print out a double value, use [CODE]printf( "%f", num ) ;[/CODE] instead. atof is to be shunned; it has …

Member Avatar for vijayan121
0
717
Member Avatar for tonyaim83

you can repesent a graph as an adjacency matrix. [URL="http://www.cs.usask.ca/resources/tutorials/csconcepts/1999_8/tutorial/beginner/matrices/matrix.html"]http://www.cs.usask.ca/resources/tutorials/csconcepts/1999_8/tutorial/beginner/matrices/matrix.html [/URL] [URL="http://www.cs.usask.ca/resources/tutorials/csconcepts/1999_8/tutorial/beginner/matrices/matrix.html"]using the specialization vector<bool> would take only one bit per matrix element, so large graphs can be accommodated. (not withstanding my efforts, the daniweb formatter refuses to believe that this sentence is not a url)[/URL] [code=cplusplus]#include <iostream> #include <vector> …

Member Avatar for vijayan121
0
131
Member Avatar for jaepi

[url]http://www-128.ibm.com/developerworks/linux/library/l-ipc2lin3.html[/url]

Member Avatar for vijayan121
0
86
Member Avatar for danysabin

to put the machine into suspend/hibernate state, use SetSuspendState [url]http://msdn2.microsoft.com/en-us/library/Aa373201.aspx[/url] to wakeup from suspend/hibernate, use SetWaitableTimer [url]http://msdn2.microsoft.com/en-us/library/ms686289.aspx[/url] with the last parameter (fResume) as TRUE and have a thread wait for the timer to be signalled or specify an APC to be called. note: to wake up from hibernate, hardware support …

Member Avatar for vijayan121
0
119
Member Avatar for em_i

if you are interested in only an approximate value, you could use a type like double for computing the result. for example, a long double can hold very large values, but precision is limited (on my compiler, the mantissa is accurate upto 15 decimal digits). [code=cplusplus]#include <limits> #include <iostream> #include …

Member Avatar for iamthwee
0
166
Member Avatar for tonyaim83

dragon's algorithm does work. here is a version which a. uses isspace (handle all char sets) b. uses erase instead of extract substrings and concatenate (little more efficient). c. continues from the next char while repeatedly searching for whitespaces (again, little more efficient) [code=cplusplus]void remove_ws( vector<string>& vertex ) { int …

Member Avatar for Bench
0
2K
Member Avatar for ishwarbg

> search the string (file name ) and read its data (file position) with a good speed. The requirement is that I have to search for 869 files. the number of files are quite small; if you have to do this search more than once, it would be faster to …

Member Avatar for vijayan121
0
98
Member Avatar for ishwarbg

bsd: [URL="http://people.freebsd.org/%7Ekientzle/libarchive/"]http://people.freebsd.org/~kientzle/libarchive/[/URL] as root, cd /usr/ports/archivers/libarchive && make install clean windows: [URL]http://gnuwin32.sourceforge.net/packages/libarchive.htm[/URL] you would need to fetch the setup program & verify the MD5 checksum manually

Member Avatar for vijayan121
0
203
Member Avatar for karimnouh

> i think im going to ask my IT teacher ... but he sucks why don't you ask this person? [url]http://www.research.att.com/~bs/bs_faq2.html#void-main[/url]

Member Avatar for Infarction
0
304
Member Avatar for orkut123

> am planning to write a simple implementation of T9 , as seen in nokia phones. Could someone suggest an efficient way to go about this ?? [url]http://en.wikipedia.org/wiki/Trie[/url] [url]http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Tree/PATRICIA/[/url]

Member Avatar for iamthwee
0
260
Member Avatar for rati

[code=cplusplus]struct singleton { // return a reference, not a pointer. the problem with returning // a pointer is that a caller might be tempted to call delete on it // returning an auto_ptr<> to a singleton is ruled out; // it's (or it's copy's) destructor *will* call delete on the …

Member Avatar for vijayan121
0
95
Member Avatar for shannonpaul

> I know the if statement would be a better choice but I must you use the switch for an assignment would this make your teacher happy? [code=cplusplus]enum { LESS_THAN_10000, NOT_LESS_THAN_10000 }; int to_be_used_in_switch = sales < 100000.0 ? LESS_THAN_10000 : NOT_LESS_THAN_10000 ; switch( to_be_used_in_switch ) { case LESS_THAN_10000: /* …

Member Avatar for vijayan121
0
128
Member Avatar for em_i
Member Avatar for em_i
1
131
Member Avatar for hoceandress
Member Avatar for vijayan121
0
134
Member Avatar for Trevora

using far pointers you are still limited by 64K memory regions; its just that, that region can be outside your current CS or DS, and you can have many such regions. pointer arithmetic on far pointers do not modify the segment portion of the pointer, only its offset (modulo 64K …

Member Avatar for Trevora
0
220
Member Avatar for prs55

> Because the code must read the digit one by one as individual characters(CHAR values)and convert them to numeric form. or you can read the literal digits into a string; this would be easier. > And you know C++ uses ASCII code for a character when it appears in an …

Member Avatar for Salem
0
143
Member Avatar for dannyadp

see: [url]http://www.daniweb.com/forums/thread85114.html[/url] note: [INLINECODE]cout << "size of file: " << sizeof(parent) << endl; //size of the parent.txt file, for test purpose[/INLINECODE]will not give you the size of the file on disk; sizeof(parent) gives you the amount of memory that the variable[I] parent[/I] takes ( as a multiple of sizeof(char) )

Member Avatar for iamthwee
0
74
Member Avatar for roflol

you do not have to close and then reopen the file; [inlinecode]inData.clear() ; inData.seekg(0) ;[/inlinecode] is more efficient. > I need the number of lines before I can correctly do the other stuff. you do not; use a vector instead of a c-style array: [code=cplusplus]#include <iostream> #include <fstream> #include <string> …

Member Avatar for vijayan121
0
201
Member Avatar for AdventChildren0

[code=cplusplus]#include <iostream> #include <string> using namespace std ; int main() { string str ; getline( cin, str ) ; cout << str << '\n' ; cout << oct << showbase ; for( size_t i=0 ; i<str.size() ; ++i ) cout << int( str[i] ) << ' ' ; cout << …

Member Avatar for Bench
0
106
Member Avatar for n.aggel

[code=cplusplus]#include <algorithm> #include <vector> #include <iostream> #include <ctime> #include <iterator> #include <boost/random.hpp> #include <limits> using namespace std ; using namespace boost ; inline double elapsed_msecs( clock_t start, clock_t end ) { return double( end - start ) * 1000.0 / CLOCKS_PER_SEC ; } int main() { // choose a reasonably …

Member Avatar for n.aggel
0
141
Member Avatar for satya.vijai

[quote=satya.vijai;417028]...I thought of doing like, 1. get the file size 2. create a char* and allocate the size of file size 3. copying the entire file into a string buffer using Readfile() API... but I think this is not ideal, so is there any other way to do it better.. …

Member Avatar for vijayan121
0
170
Member Avatar for Tight_Coder_Ex

dynamic scoping is almost never used these days. with dynamic scoping, a variable reference is bound to the most recent instance of that variable on the call stack. for example: [code=cplusplus]#ifdef this_should_not_compile void b() ; void c() ; void a() { int x = 24 ; int y = 32 …

Member Avatar for Salem
0
121
Member Avatar for sammy_raul

you cannot apply a dynamic_cast on a void* to get a non void pointer. except in a trivial case, in dynamic_cast<T>(v), v should be a pointer to or an lvalue of a polymorphic type. if T is a (cv qualified) void* , and v is a pointer to a polymorphic …

Member Avatar for vijayan121
0
108
Member Avatar for rosemary

[inlinecode]// .... while(! infile.eof()) { infile>>sentense; continue; count+=letter; cout<<"The letter a repeated"<<count<<"times(s)"<<endl; } // ... [/inlinecode] the continue does nothing (other than perhaps satisfy your teacher) and the statements following it in the loop would be silently ignored by the compiler during code generation. you should change it to if( …

Member Avatar for vijayan121
0
335
Member Avatar for JRM

ZN10FindDialogC2EP7QWidget is the result of the c++ compiler embedding type/namespace information in names (this is called name decoration or name mangling) . see: [url]http://en.wikipedia.org/wiki/Name_mangling#Complex_example[/url] for an example. you have probably inherited virtual functions from the base class QDialog and i think you are not linking to the library that contains …

Member Avatar for vijayan121
0
205
Member Avatar for Allan03

Dragon's suggestion of SystemTimeToVariantTime is the easiest way, but might give you inaccurate resuts if you need sub-second resolution for time. see: [URL]http://support.microsoft.com/kb/297463[/URL] if you need millisecond resolution, more work is required [code=cplusplus]inline unsigned __int64 to_integral( const SYSTEMTIME& st ) { FILETIME ft ; SystemTimeToFileTime( &st, &ft ) ; ULARGE_INTEGER …

Member Avatar for Ancient Dragon
0
830
Member Avatar for khalidxa

[quote=khalidxa;412982]... when I run the program, it returns a memory address. I want it to return the value for the array.[/quote] array names 'decay' into pointers (addresses); this is fundamental to their use in C and C++. to return an array by value, you could either wrap a structure around …

Member Avatar for Salem
0
174
Member Avatar for jerryseinfeld

if it is c++, using boost.tokenizer would be the easiest way. [code=cplusplus]#include <iostream> #include <fstream> #include <boost/tokenizer.hpp> #include <string> #include <vector> #include <iterator> #include <boost/lexical_cast.hpp> using namespace std; using namespace boost; struct abc { explicit abc( const string& line ) ; string x ; string y ; int z ; …

Member Avatar for vijayan121
0
497
Member Avatar for nubbie

[code=cplusplus]#include <iostream> #include <limits> using namespace std ; inline double get_double() { double value ; if( cin >> value ) return value ; cout << "you have to enter a number!\n" ; cin.clear() ; cin.ignore( numeric_limits<streamsize>::max(), '\n' ) ; return get_double() ; }[/code]

Member Avatar for WaltP
0
122
Member Avatar for mooncry

[code=cplusplus]// ISO/IEC 10646:2003(E) is available for free download from http://standards.iso.org/ittf/PubliclyAvailableStandards/c039921_ISO_IEC_10646_2003(E).zip // unicode 5.0 has the same character repertoire as // ISO/IEC 10646:2003 with Amendments 1 and 2 applied. // in g++ and microsoft c++, wchar_t is unicode 5.0. using either, #include <iostream> #include <string> using namespace std ; int main() …

Member Avatar for vijayan121
0
134

The End.