518 Posted Topics
Re: Its a project-euler.net problem No. 67 Right? >My program for this program is not working >can you please help. Perhaps not. Seriously, I don't have enough time to spend and debug your code but I do can help you by guiding you to a correct algorithm: Go the the second … | |
Re: >You return a variable that ceases to exist after the function all (a >variable local to the called function). Generally speaking, pass a >pointer (to the start of the array) and then modify it in the called >function. Exactly. I know some other person could have given advice to return … | |
Re: Re-factor the simplify function which finally converts a/-b to -a/b. This will maintain uniformity and thus the program will be unambiguous. | |
Re: >>write a recursive function to convert integer into string. Your function will work good for all positive integer but would fail when N=0. IntToString(0)="" | |
Re: >i'm a noob in C++ can any kind soul please help me Not until you show any efforts. Sorry. Time out. Best next article for you: [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: Oh jazzman please. Stop posting rusted C++ code. Read this [url]http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html[/url] to migrate to standard C++ | |
Re: >it's me 4101 Oh yeah! Even my real name is 312515473215781215487451 but I let them call me Siddhant so that they remember me. | |
Re: You really need to go down to the basics of inheritance - why we use it. When you construct a base class, it is not really a base class but it is 'just a class'. It is [I]when[/I] you use that class to derive a child class, the former becomes … | |
Re: Did you ever thought of doing your work yourself? Simply stating "I want this" do not work. At least put an effort and then ask for help. Read [url]http://www.daniweb.com/forums/thread202628.html[/url] or[URL="http://www.catb.org/~esr/faqs/smart-questions.html"] this[/URL]. Hint: use recursive functions. | |
Re: There you go. You have finally done it. And all these ^^ don't know about the conspiracy about making some crazy thread. Oops......... Yeah sure, void main is my favorite too. ^H^H^H^H^H^H^H^H^H | |
Re: >Any advice how to put each line in its own array element? Not really but it would be better to apply brains and re-factor the code provided by twomers. Declare an array of N std::strings and then iterate with a forloop to read one line by one with help of … ![]() | |
Re: Well, another "criticize my code" question. Good. Here are my advices: [LIST] [*]Try not to implement the code which has been provided to you by the standard library. This way you will make shorter and elegant code. [*]Avoid magic number: [ICODE]stCOMMA_LOC + 2[/ICODE] ,[ICODE]stCOMMA_LOC && nCounter < 7[/ICODE]. Rather, put … | |
Re: >Even the delete operator is executed, the last two output statements are working >same the first two output statements. This is implementation specific. On my implementation the two outputs are different: [code]siddhant3s@Xion:~$ g++ tester.cpp -otester.exe &&./tester.exe p's add is 0x804a008 value in p is100 p's add is 0x804a008 value in … | |
| |
Re: Read this post : [url]http://www.daniweb.com/forums/post873624.html#post873624[/url] | |
Re: >If the size is determined at runtime you need a full fleged dynamic memory >version. Something like A full fledged dynamic memory version? Is that what you call your program you just posted. It would be so much better to rely on the standard headers than your memory leaking program. … | |
![]() | Re: Don't keep bumping on your thread. No one is free enough to help you if you don't show effort. I have see many thread started by you stating "How do I do this" without any efforts. Learn to ask question the smart way : Read this page [url]http://www.catb.org/~esr/faqs/smart-questions.html[/url] Also, read … |
Re: >I want the vector to be of type 'this' What do you mean by 'this'? Do you want a vector of [I]pointer to the[/I] same class you are in. Or Do you want a vector of the same class you are in. If you wan't the former one, look at … ![]() | |
Re: Even the use of standard C++ ( with int main, standard headers) would be nice. Read [url]http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html[/url] sections 2.1, 2.2 and 2.3 | |
Re: Learn a GUI library. wxWidgets is a good one :[url]http://zetcode.com/tutorials/wxwidgetstutorial/[/url] | |
Re: >These can be fun to build! Start simply two operands, one operator! then work up! Definitely not!! If you are building it for educational purposes fine; otherwise it is not recommended to hand code a lexer[1] yourself. To OP: If you 'project' is whole about building a lexer, the above … | |
Re: Read [url]http://c-faq.com/aryptr/pass2dary.html[/url] | |
Re: I remember me facing the same problem a year ago. I used the following hack rather than calling on [URL="www.boost.org/doc/libs/release/libs/serialization/"]boosts serialization [/URL]: Lets say we have a string [B]sring_to_be_written[/B] which I want to serialize: 1. I first write down the s.size() using fstream::write(): [code=cpp] size_t size=string_to_be_written.capacity()+1; ofile.write(reinterpret_cast<char *>(&size),sizeof(size));[/code] 2.Next I … | |
Re: @Dave I too was thinking about this catch; later only I read your post. The solution would be this: [code=cpp] do std::cout << "Enter a number: "; while( std::cin >> tmp && tmp != -1 && (1 || (sum += tmp)) );[/code] but as you said, neither me is a … | |
Re: [url]http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.16[/url] Read from 16.16 to 16.19 and then try to implement the `features' of what you are talking about. If in trouble, ask the specific question. | |
Re: What a pity, you are still struck at a 18 year old compiler. Read[URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html"] this[/URL] to migrate to a better compiler. Sorry, But I am on a social movement about "anti old compilers" so I won't/can't help you. | |
Re: Everything is fine except that both of you missed an important point: [B]private members are not inherited.[/B] And if you know or not, the default access code of a class is private. Hence the [I]int a,b,c;[/I] in post#1 and the [I]void SayHello()[/I] in post#2 are declared as private. They cannot … | |
Re: Understand what exactly #include<header.h> does: It simply copy-paste the content of header.txt and replaces it with the line containing #include<header.h> Say, if you have a header.h with the following : [code]+--header.h---------------------------------+ +-------------------------------------------+ | Sticks and Stones can break my bones. | | But they can't break my soul. | |___________________________________________|[/code] … | |
Re: >Well, you could try using the derived maths functions: Why would he when he already have asin and acos? Besides why did you complicated the formula for acos(x) which is simply: [tex]acos(x) = \frac{\pi}{2}-asin(x)[/tex] | |
Re: Read [URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html"]this[/URL] if you are using a crap like Turbo C. | |
Re: BTW, 100! is [CODE]93326215443944152681699238856266700490715968264381621468592963 89521759999322991560894146397615651828625369792082722375825118 5210916864000000000000000000000000[/CODE] There is no fundamental integral datatype in C++ which can store this. @Vernon Good catch. | |
Re: file.write() methods write unformatted characters to the file. That is, it do not work like a print statement. When you issue a print statement, a new line is automatically appended. This is not the case with write(). write() performs as-is writing. You could redirect your stdout to a file and … | |
[U][B]Guidelines to OPs:[/B][/U] [U]Before you start a thread:[/U] Starting a thread is a critical task. It is so because it demands time and attention of other forum members. A thread should only be started when you have done enough drill to find your answer else where. You should always be … | |
Re: In a hurry: find answer at [url]http://www.gamedev.net/community/forums/topic.asp?topic_id=485378[/url] | |
Re: Another thread where the OP got a pre-cooked pudding(tasteless though). | |
Re: The std::vectors uses heap storage (dynamic memory management). When you declare an vector, vec1, all you do is instantiate a vector object. When you push_back elements in a vector, it automatically manages it and store it somewhere in the memory and stores pointers to those object with it. So now … ![]() | |
Re: In general, no. But you can wrap the clock() inside a class and simulate a reset method: [code=cplusplus]class Clock { private: clock_t naught; public: Clock():naught(0){} //constructor void reset() { naught=clock(); } clock_t operator()() { return clock()-naught; } }; //demonstration: int main() { using std::cout;using std::endl; Clock stopwatch; while(stopwatch()<2 * CLOCKS_PER_SEC); … | |
Re: >>Don't you love newbie questions?? Yes but not the trivial ones. Your question is quite trivial to even look at. There were enough resources available only if you would [URL="http://www.catb.org/~esr/faqs/smart-questions.html#rtfm"]STFW[/URL]. You wasted my minute to even look at your question. You either enjoy sadistic pleasure or you are too lazy. … | |
Re: There are a [URL="http://www.packetstormsecurity.org/programming-tutorials/C++/c++-faq/input-output.html#[15.1]"]lot of reasons[/URL] to love iostream. Standards don't say that iostream is slower or faster than stdio. But usually iostream is build by wrapping stdio hence it is usually slower in the current implementations. Until and unless you have a [I][B]VERY GOOD REASON[/B][/I] to use stdio, I … | |
Re: >search is a standard name declared in the <algorithm> header. It's a very bad >idea to use standard names even if you don't include the header because other >standard headers could include it. Indeed, This is why you are advised to explicitly qualify the names of a namespace rather than … | |
Re: ISO C++ need you to explicitly mention the datatype after the 'const'. At the moment of defining C1, C2 is not defined. Read [url]http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.11[/url] | |
Re: I would recommend a reading to [url]http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.16[/url] for a complete reference. None of the above has highlighted that the above techniques will not make the matrix contiguous except post#3. | |
Re: Tell me how much time did you spent on a search engine to find your answer. In technical terms, 'saving' is known as [URL="http://en.wikipedia.org/wiki/Serialization"]serialization[/URL][1] There are plenty of libraries out there to serialize STL containers. You are fortunate enough that [URL="http://www.boost.org/doc/libs/1_39_0/libs/serialization/doc/index.html"]Boost's Serialization Library[/URL] is there on your demand. [URL="http://www.codeproject.com/KB/stl/STL_Serialization_Library.aspx"]Another library[/URL] … | |
Re: > "[ CODE ] and [ /CODE ]" without the spaces. Next time you can use the noparse tag to tell the exact usage. [noparse][noparse] bbTags are not parse with this tag. Even if you type [code][/code] it will appear as it is. This example was created using two noparse … | |
Re: >I won't allow myself to use that as it's just too foreign on a windows machine. I don't agree. Python guarantees that the '/' will be converted to whatever underlying platform is using. Hence it is *always* portable to use '/' instead of '\'. This guarantee is actually from the … | |
Re: >As you see in the server's response last-modified header is not set. In this >circumstances, how to force the server to give data only if the cached page at >user has been modified by the server instead of the server making every >response refreshed. Not all server support this facility. … | |
Re: Yes, it is not possible. But ask your self: you you really need it? I never felt need of such a thing. The only close alternative is to use a [URL="www.cplusplus.com/reference/stl/map/"]std::map[/URL] something like this: [code=cpp] int main() { using std::map;using std::string;using std::cout; using std::cin; map<string,int> m; m["i"]=1; m["k"]=5; m["ok"]=53; string … | |
Re: >Though people prefer using atoi() which is not a standard and which is basically >the "C" way of doing it [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/"]atoi[/URL] is as standard as the stringstream solution. The only problem is that it is not that 'good'. By good means that as the stringstream solution will rely on the … | |
Re: Copy constructor is invoke when you initialize an object with another. In this case, it will be invoked something like this: [code=cpp] LDAPControlSet a; //do something with 'a'. LDAPControlSet b=a;//copy constructor invoked with 'a' as the argument LDAPControlSet c; c=b;// copy constructor *not* invoked but initialization operator invoked LDAPControlSet d(a);//explicit … | |
Re: You can do something like this: [code=cplusplus] int myints[] = {16,2,77,29}; vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) ); [/code] |
The End.