1,247 Posted Topics

Member Avatar for Infeligo

the problem with the code using unsigned it is that nowhere in the c++ standard does it say [ICODE]std::numeric_limits<unsigned int>::max() >= 2^32 - 1[/ICODE] or for that matter, [ICODE]std::numeric_limits<unsigned int>::radix == 2[/ICODE] or [ICODE]std::numeric_limits<unsigned int>::digits >= 32[/ICODE]. so the code may fail for some input values on some implementations. the …

Member Avatar for vijayan121
0
475
Member Avatar for dkwantee

[code]int main() { int numbers[4]; int i; ifstream streamin; streamin.open("input.txt"); for(i=0;i<4;i++) { streamin >> numbers[i] ; } // [COLOR="Red"]what is the value of i at this point?[/COLOR] cout << numbers[i]; streamin.close(); }[/code]

Member Avatar for mitrmkar
0
254
Member Avatar for sgw

this is one way to do it. [code=c++]#include <iostream> #include <sstream> #include <iomanip> int main() { std::ostringstream stm ; stm << '$' << std::fixed << std::setprecision(2) << 123.4567 ; std::cout << std::setw(11) << std::setfill(' ') << std::right << stm.str() << '\n' ; }[/code]

Member Avatar for sgw
0
132
Member Avatar for juanbuffer

> my first time using shared memory and I'm really discouraged. it is just that the problem is (much) harder than you imagine it to be. for this to work, a shared memory segment should be created once and when allocate is called we have to sub-allocate memory blocks out …

Member Avatar for juanbuffer
0
660
Member Avatar for jesseb07

you could use librsync [url]http://librsync.sourceforge.net/[/url] to install (*BSD): as root, [ICODE]cd /usr/ports/net/librsync && make install clean[/ICODE] or for binary package: as root, [ICODE]pkg_add -r librsync[/ICODE]

Member Avatar for jesseb07
0
174
Member Avatar for Jennifer84

[CODE]// .. { this->progressBar1->Value = (out / count) * 100; this->progressBar1->Invalidate() ; this->progressBar1->Update() ; // if immediate repaint is required } // ..[/CODE]

Member Avatar for vijayan121
0
98
Member Avatar for unclepauly

> In reality FuncA is a normal function in an exe, and FuncB is a function on a COM interface > (so FuncA actually calls CoCreateInstance before calling FuncB on the COM object). > And inside FuncB, DoSomethingElse is actually an ADO function that i am calling > on one …

Member Avatar for vijayan121
0
112
Member Avatar for jrivera

the problem is that you are calling a virtual function during the construction of the base class. this will not behave the way you expect it to behave; the wrong vtable is being pointed to at the time. if you call virtual functions during construction or destruction, such calls will …

Member Avatar for vijayan121
0
102
Member Avatar for vs49688

[CODE]std::string runasc "runas /profile /user:tsc\\staffuser" ; system( ( runasc + " " + programc ).c_str() ) ;[/CODE]

Member Avatar for Nick Evan
0
106
Member Avatar for Swati_bansal
Member Avatar for farag
0
276
Member Avatar for msk88

for XP Professional: from the command prompt execute [B]gpedit.msc[/B] go to: Computer configuration --> windows settings --> scripts (startup/shutdown) choose Shutdown and add your script/command.

Member Avatar for prushik
0
146
Member Avatar for vileoxidation

[CODE]#include <iostream> using namespace std; int main(int, char**) { long long n = 6647817899LLU; long long f = 10299685494LLU; int i = ((f - n) / [COLOR="Red"]double(n)[/COLOR] ) * 100; cout << "Part 4: " << f << " is " << i << "% more than " << n …

Member Avatar for vileoxidation
0
88
Member Avatar for kux

> I heard something that boost's preprocessor library can do that. > didn't get to try it out : [url]http://boost.org/libs/preprocessor/doc/ref/repeat.html[/url]. BOOST_PP_REPEAT gives a fast horizontal repetition from 0 to N-1 since you need a repetition starting at 1, using BOOST_PP_REPEAT_FROM_TO would be easier. [code=c++]#include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/repetition/repeat_from_to.hpp> #include <iostream> #define …

Member Avatar for vijayan121
0
185
Member Avatar for ithelp

the major disadvantage of dynamic analysis is that its results may not generalize to future executions. there is no guarantee that the test suite over which the program was run (that is, the set of inputs for which execution of the program was observed) is characteristic of all possible program …

Member Avatar for vijayan121
0
94
Member Avatar for ventrica

> ... so, what should i change in the coding to solve the problem? change the return type from void to bool [CODE]template < class DataType> class List { // ... [COLOR="Red"]bool[/COLOR] Traverse(DataType, int &); // ... };[/CODE]

Member Avatar for vijayan121
0
426
Member Avatar for Jennifer84

[QUOTE=Jennifer84;536793]I have 2 Forms in my Windows Form application. Form1 creates .txtfiles. I open Form2 from Form1 and can see the .textfiles that is created in a comboBox3. If I open the application from the beginning and go to Form2 I will see all .txt files that exists in a …

Member Avatar for Jennifer84
0
106
Member Avatar for lordsvae

> It has to be like this; "CurrentDirectory" + "\\test.jar" or something. so just use a relative path "test.jar". and put the .exe and the .jar in the same folder. [CODE]ProcessStartInfo^ minProssesStartInfo = gcnew ProcessStartInfo( "test.jar" ) ; [/CODE]

Member Avatar for vijayan121
0
96
Member Avatar for abidbhat

the simplest way would be to use a streambuf that outputs to the control the skeleton would be: [code=c++] #include <streambuf> class textbox_streambuf : public std::streambuf { // ... protected: virtual int overflow( int c = traits_type::eof() ) { if ( c != traits_type::eof() ) { char cc = traits_type::to_char_type(c); …

Member Avatar for vijayan121
0
83
Member Avatar for hyperzero4

[code=c++]#include <string> #include <algorithm> #include <iostream> using namespace std ; int main() { string MyString = "The rabbit likes to ea! carro!s"; cout << MyString << '\n' ; replace_copy( MyString.begin(), MyString.end(), MyString.begin(), '!', 't' ) ; cout << MyString << '\n' ; }[/code]

Member Avatar for John A
0
4K
Member Avatar for mario123

The definition `void main() { /* ... */ }` is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1. A conforming implementation accepts `int main() { /* ... */ }` and `int main(int argc, char* …

Member Avatar for Narue
0
404
Member Avatar for vishalkhialani

> The data is basically alot of text and integer values. > It needs to be accessed, sorted and filtered > Not much data will be added maximum size will go to 400K just use a simple xml file to store the data. and an xml parser library eg. [url]http://www.grinninglizard.com/tinyxml/[/url]

Member Avatar for vishalkhialani
0
164
Member Avatar for icewizard

> since I only defined function() once. you defined it twice. once in a.cpp and once in main.cpp (which includes a.cpp)

Member Avatar for John A
0
262
Member Avatar for JRM

> Anyone been there, done that? no, i haven't done anything of the kind. but i do know that the *bsd unixes do provide (sometimes limited) binary emulation for a variety of operating systems. i think NetBSD would be the best option for attempting this. the part of the kernel …

Member Avatar for vijayan121
0
148
Member Avatar for gcardonav

the exception thrown is of type [B]float[/B], not [B]int[/B] you have to catch it as a float. [icode]catch( float nValue ) { /* ... */ }[/icode]

Member Avatar for gcardonav
0
100
Member Avatar for Jennifer84

> I have: Directory::GetFiles(Files,"*.txt"); > Files is in a format: cli::array<Type,dimension> ^ > How could Files be converted to System::string ^ presumably, the Type in [ICODE]cli::array<Type,dimension>[/ICODE] is wchar_t and the dimension is 1. all cli array types derive from [ICODE]System::Array[/ICODE] and you could directly use the constructor of a [ICODE]System::String[/ICODE] …

Member Avatar for Jennifer84
0
159
Member Avatar for linux0id

> I have seen some code where some variable gets inserted into string through the % sign the code you saw was probably using the [B]Boost.Format[/B] library to insert stuff into a stringstream. [url]http://www.boost.org/libs/format/doc/format.html[/url]

Member Avatar for linux0id
0
13K
Member Avatar for C41R0

> how do i make the final calculation become 41.6 ? [code=c++]#include <iostream> #include <iomanip> #include <sstream> int main() { std::cout << 374.0 / 9.0 << '\n' ; std::cout << std::fixed << std::setprecision(1) << 374.0 / 9.0 << '\n' ; std::stringstream stm ; stm << std::fixed << std::setprecision(1) << 374.0 …

Member Avatar for C41R0
0
207
Member Avatar for kalpana0611

write a function to covert a text file to an xml file. have two nested loops; the outer one to iterate over the folders, and the inner one to iterate over files in that folder. [code=c++]#include <fstream> #include <string> #include <iomanip> #include <sstream> void convert_to_xml( std::istream& in_file, std::ostream& out_file ) …

Member Avatar for kalpana0611
0
204
Member Avatar for Darth Vader

[url]http://msdn2.microsoft.com/en-us/library/1b4az623.aspx[/url] [url]http://msdn2.microsoft.com/en-us/library/1b4az623(VS.80).aspx[/url] [url]http://blogs.msdn.com/slippman/archive/2004/06/02/147090.aspx[/url]

Member Avatar for vijayan121
0
112
Member Avatar for cranfss

> I'm wondering if there is a more elegant solution. perhaps use a parser framework like boost.spirit [url]http://www.boost.org/libs/spirit/index.html[/url]

Member Avatar for vijayan121
0
137
Member Avatar for jetru

a commonly used architecture is [url]http://en.wikipedia.org/wiki/Model-view-controller[/url] > Right now, I'm thinking along the lines of having two main objects, a Screen and a Handler these roughly correspond to view and controller lines, circles etc. would be part of the model.

Member Avatar for vijayan121
0
182
Member Avatar for jov0708

or use a union [code=c++]int main() { typedef unsigned char byte ; union { byte buffer[ sizeof(long) ] ; long key ; }; // ... }[/code]

Member Avatar for TimeFractal
0
2K
Member Avatar for Ashu@sym

> the following piece of simple code(it didn't work in any of the compilers VC++,GCC etc) the code is incorrect and should not compile without an error. this is (a simplified version) of what the standard says about while loops: [quote]in [B]while(condition) substatement[/B] the condition is one of i. expression …

Member Avatar for vijayan121
0
162
Member Avatar for VersEtreOuNe

[CODE]template<typename DataType> class Value { // ... Value& operator +(const Value& aValue); // .. }; template<typename DataType> Value<DataType>& Value<DataType>::operator +(const Value<DataType>& aValue) { /* ... */ } [/CODE] this [B]operator+()[/B] only allows two Value template instantiations for the same DataType to be used. ie. you could add a [B]Value<int>[/B] to …

Member Avatar for VersEtreOuNe
0
114
Member Avatar for sjcomp

> For some reason reference to operator() bothers me. Am I missing something simple? one reason why this may be a bother is possible loss of efficiency. a function called via a pointer is usually not inlinable. (what a pointer points to is techically something that is known only at …

Member Avatar for vijayan121
0
107
Member Avatar for sgw

your compiler may require [ICODE] c = std::pow( a, b ) ;[/ICODE]. this is correct as you are using <cmath> (not math.h) the more likely reason is that the function pow is overloaded in c++ [code]double pow ( double base, double exponent ); long double pow ( long double base, …

Member Avatar for sgw
0
655
Member Avatar for Undertech

this is an issue in the c++98 standard. this has been addressed by The Library Working Group (LWG), the ISO subcommittee responsible for making changes to the std c++ library. a proposed resolution to this [url]http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#136[/url] has been adopted in the Tokyo meeting of the LWG (2000?) and should make …

Member Avatar for vijayan121
0
196
Member Avatar for jrkeller27

> stores each unique word and the frequency it appears in the text file. > This information is stored in a multimap<string, int> it would be simpler to use a [B]std::map<std::string, int>[/B] (instead of a std::multimap) [code=c++]std::map<std::string, int> word_count ; std::string word ; while( read_next_word( file, word ) ) ++word_count[word] …

Member Avatar for vijayan121
1
118
Member Avatar for sjcomp

yes, it is valid (and as efficient and more flexible) to use &Base::Go instead of &Derived::Go. pointers to member functions do not support an operator(); so they are used as if [B]boost::mem_fn[/B] has been used to convert the member pointer into a function object. [B]boost::bind(&Base::Go, _1)[/B] is equivalent to [B]boost::bind( …

Member Avatar for vijayan121
0
118
Member Avatar for sjcomp

you would have to iterate through the vector and remove each element that is reset. moving all the reset elements to the back of the sequence and then doing a single erase of elements at the end of the vector (as in your code) seems to be the most efficient …

Member Avatar for vijayan121
0
126
Member Avatar for VIeditorlover

> is there a way how to ... kill process at once? posix: [B]kill( process_id, SIGKILL ) ;[/B] [url]http://www.hmug.org/man/2/kill.php[/url] [url]http://www.hmug.org/man/3/signal.php[/url] windows: [B]TerminateProcess( process_handle, exit_code ) ;[/B] [url]http://msdn2.microsoft.com/en-us/library/ms686714(VS.85).aspx[/url]

Member Avatar for vijayan121
0
128
Member Avatar for sjcomp

RTTI introduces both space and time overheads. there is a per class space overhead to store the type information; most implementations use about 40 bytes or so per class. finding the type_info (typeid on a reference to polymorphic type) involves getting to the vtable and locating the most derived class …

Member Avatar for vijayan121
0
111
Member Avatar for fromme

> Can any 1 brief me abot, what static code analysis is. [url]http://en.wikipedia.org/wiki/Static_code_analysis[/url] > And few links, where i can get freeware or open source codes for such analysing tools [url]http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis[/url]

Member Avatar for vijayan121
0
105
Member Avatar for Bazman76

> error C2297: '%' : illegal, right operand has type 'double' the error message says it all, doesn't it? > should I convert result of power to type int? yes. either [ICODE]binary % ( i * int( pow(10,i) + 0.5 ) ) ;[/iCODE] or [ICODE]binary % ( i * int( …

Member Avatar for Bazman76
0
148
Member Avatar for jenymaru08

> how will you make your structure be in within structure ??? at the namespace level [code=c++]struct outer { // ... struct inner { // ... }; // .... };[/code] at the object level [code=c++]struct composite { // ... outer member_one ; outer::inner member_two ; // ... };[/code]

Member Avatar for hu_is_anonymous
0
149
Member Avatar for Arctic

[CODE]char* soundex( const char word[], char sound[] ) { // ... sound="Z0000"; // *** trouble **** // ... }[/CODE] a literal string (eg "Z0000") consists of non-modifiable chars. if you had enabled all warnings, the compiler would have alerted you that something was amiss here. eg. [B]warning: deprecated conversion from …

Member Avatar for vijayan121
0
160
Member Avatar for johnRiley

> Hmmm, is there any significant, practical difference? > I think not. Remember, that was 40 billion iterations. for standard types like int or double, it would not make any difference. the compiler knows everything about these types and can see that [icode]a = a + b ;[/icode] and [icode]a …

Member Avatar for vijayan121
0
134
Member Avatar for vishalkhialani

> which compiler is the most popular the two mainstream c++ compilers are g++ (part of gcc) and vc++ (microsoft). and it is probably a good idea to stick to one of these; they are the most popular and attract the best support from third-party library and tool developers. both …

Member Avatar for vijayan121
1
198
Member Avatar for faisaly

for storing and accessing a sequence of objects in memory, you cannot have a construct more efficient (in terms of both time and space) than an array. it is, however, also a very low level data structure with two fundamental properties: a. an array doesn't know its own size. b. …

Member Avatar for vijayan121
0
292
Member Avatar for NorseMN

[url]http://www.boost.org/doc/html/any.html[/url] [url]http://www.boost.org/doc/html/variant.html[/url] you may also find this discussion on static typing technology at large interesting. [url]http://groups.google.com/group/comp.std.c++/browse_thread/thread/da71464ad690d506/303e3bf2407a7609?lnk=st&q=min+max+c%2B%2B+#303e3bf2407a7609[/url]

Member Avatar for Ancient Dragon
0
1K

The End.