6,741 Posted Topics
Re: >here is code for ur problem Giving away homework answers is frowned upon here. >#include<iostream.h> We're well beyond the point where this will fail to compile on many modern compilers. I recommend you get with the times. >int array[1000000] This is a terrible waste of memory and it's also a … | |
Re: To pack? Are you going on a trip? :icon_rolleyes: >for sure i want to knw C++ and JAVA. But i dnt knw the third! If you want to go the practical route, select a language you're likely to use. Perl and Python are both good options. If you intend to … | |
Re: >Anyone got any idea how to enable support in GCC or where is the actual problem ? What you want (to a point) is some kind of extended character set for your compiler. Unicode is widely supported by compilers these days, so for example you can already change "Hello" to … | |
Re: >template <class T> >Element* Btree<T>::recins( T& obj, Element* cpoz ) Element is a dependent type, so you need to be very specific about what it is: [code=cplusplus] template <class T> typename Btree<T>::Element* Btree<T>::recins( T& obj, Element* cpoz ) [/code] >Element *p = new Element( T ); T is a type, … | |
Re: Sounds like the low virtual memory notification. Kill as many unnecessary processes as you can and see if it goes away. You may need to clean up the programs that start automatically as well. | |
Re: >Kindly tell me in brief that " impct of OO paradigm on software development (programming)" The positive impact is that people are now (more or less) unwittingly using good design practices where those same practices were largely ignored by the masses before OO became all the rage. The negative impact … | |
Re: [QUOTE=Ancient Dragon;651680]You formed the string incorrectly [icode]ItemFile.open((string)(ItemID+".asw").c_str());[/icode][/QUOTE] The result of operator+ for std::string is always going to be a new std::string of the same type, so your cast is redundant. This is cleaner: [code=cplusplus] ItemFile.open((ItemID + ".asw").c_str()); [/code] | |
Re: >My problem is that I am not quite sure how I have to think. Think in terms of an expression tree, just like any other expression. The only difference here is accurately handling short-circuiting on top of precedence. | |
Re: >1) im still lost on, i know the three types of loop but not >the method to discover which one to use and when. You use the loop best suited to the problem. For example, if you always execute the body of the loop at least once, a do..while loop … | |
Re: You're printing a pointer, of course the result will be an address. Try dereferencing brd: [code=cplusplus] cout << *brd; [/code] | |
Re: >they create and initialize everything under main function as one source code program. How far into the book are you? Beginner books generally keep it simple at first and ease into full blown OO techniques. Also, don't forget that C++ is [b]not[/b] an object oriented language, it's a multi-paradigm language … | |
Re: >and take it easy on the code, I am varry new to CPP. I am at the hello world level. Since you've specified mutually exclusive requirements (relatively non-trivial tasks and code at the hello world level), I'll simply suggest you learn more C++ before trying to do this. | |
Re: Can you post main.cpp as well? | |
Re: >Should I then just remove or modify the tests, too? That makes sense. You should also modify the tests that rely on that class as well, which (depending on your level of coupling) could mean changes in other classes and other tests. | |
Re: >Actually, I find just as many people use plain text code tags or try to specify a >language and get the syntax wrong as people who don't use code tags at all. Looking at the statistics of cases we moderators deal with on a daily basis, failure to use code … | |
Re: Well, it seems you haven't had any trouble with the process of starting a thread, so now the only problem is figuring out which forum is best suited to your question. Might I suggest one of the Windows forums that matches your version? | |
Re: >So, what is the difference between NULL pointers and bad pointers Null pointers have a predictable value while bad pointers do not. >why do the delete statements fail with the bad pointers? "Bad pointers" happen when you fail to initialize a pointer, manage to corrupt your memory, or try to … | |
Re: >Now the idea is if b is equal to 5 then it breaks out of >the if loop, the for loop c, the for loop b, the for loop a. Nope. You can write as many breaks as you want, but only the first one will have any effect, and … | |
Re: I wouldn't say that we've entered the realm of issuing infractions quite yet, but it's getting closer. kv79, I'd suggest you refrain from even implying that you intend to spam or engage in DoS attacks in the future. | |
Re: You've stumbled on a gray area, but the long and short of things is that what you're trying to do is illegal in standard C++, and all of the direct workarounds are also illegal. An explicit specialization needs to be in the enclosing namespace scope, which would place it outside … | |
Re: >C# and C#.NET are the same thing. Technically that's not true. C# is an internationally standardized language that isn't bound to the .NET framework as long as the implementation conforms to the CLI specification. The .NET framework is one such implementation. Mono is another. >can anyone please enlighten me? C# … | |
Re: [code=cplusplus] #include <iostream> #include <map> #include <string> std::string foo() { return "Foo"; } std::string bar() { return "Bar"; } int main() { std::map<std::string, std::string (*)()> m; // Map the functions to the names m["foo"] = &foo; m["bar"] = &bar; // Display all of the mapped functions std::map<std::string, std::string (*)()>::const_iterator it … | |
Re: >make the int small global Yea, that's bad advice. >Globalizing variables ROX!!! You're just messing with us, aren't you? | |
Re: How about you give us some real code that compiles and gives you the error. :icon_rolleyes: It's kind of hard to tell you how your code is wrong when you summarize it using pseudocode. | |
Re: >while(fgets(pStrings, sizeof(pStrings), spIn)) That's bad on several levels. Now, I could tell you why it works, but I'd rather tell you why it's wrong. pStrings is an array of pointers to char, but fgets expects a single pointer to char. At the very least you should be passing pString[i] as … | |
Re: Accelerated C++ by Koenig and Moo fits all of your requirements that aren't terribly subjective or reliant on a specific implementation. I think it's a fun read, but you might not. The code is standards compliant, which means it'll work on every compiler that conforms to the standard (Visual C++ … | |
Re: >but I think this solution is not efficient. Why? If you're just guessing or using your "programmer's intuition", you're probably wrong. Interviewers (good ones) tend to smile more on people who aren't afraid to say "I'd rather optimize clean, correct code than fix fast code". That's the sign of an … | |
Re: >my prof gave me this sample program If you haven't modified it, then I would suggest you drop that professor and find another that can actually teach you C++. >Please help me.I need this by tomorrow... Please show us your attempt. If you need this by tomorrow then that means … | |
Re: >I want it to be infinite, if possible. Then you need to write something that can build a buffer of variable length from chunks returned by _cgets (_cgets_s in this case because you want length checking): [code=cplusplus] std::string console_read() { std::string result; char buffer[82]; std::size_t nread; while ( _cgets_s ( … | |
Re: >void main() Use this as a template: [code=c] #include <stdio.h> int main ( void ) { /* Your code here */ return 0; } [/code] >clrscr(); Unnecessary, anti-social, and you forgot to include <conio.h>. >getch(); Unnecessary, non-portable (use getchar if you must), and you forgot to include <conio.h>. >but i … | |
Re: >we did not have the right team in place to answer customer inquiries. Translation: "We hadn't yet hired someone to troll the web looking for threads discussing our company." :icon_rolleyes: | |
Re: >warning: passing arg 1 of `fread' makes pointer from integer without a cast It's generally a good idea to fix your warnings. In this case, check the documentation on fread and you'll notice that it takes a pointer to void as the first argument, not an int. | |
Re: >wanted you to help me out with a useful link related to the subject..... Given that your original post can only be described as gibberish, the only useful link I can come up with is [url]www.google.com[/url]. | |
| |
Re: >can somebody tell me is there a problem in it ? Assuming boolean is a typedef, there's nothing syntactically or semantically wrong with that function. Perhaps if you told us what it's supposed to do, we can tell you if it actually does it. | |
Re: There are two possible interpretations here: 1) Any discussion of P2P software is prohibited because the software may be used to obtain pirated software or other illegal materials. 2) The clause refers to the specific act of obtaining illegal materials using a P2P program, so discussion of legal use is … | |
Re: >What is the situation where quadratic probing is better than chaining? Chaining takes up more memory, so if storage is tight, one of the open addressing schemes would be better suited. The time it takes to chase pointers in a chained solution might also be prohibitive, in which case an … | |
Re: >i wanted to make it restart the computer if the wrong passwords entered That's one of the worst ideas I've ever heard. What if other users are logged onto the system? Are you going to kill their session just because somebody fat-fingered a password? What if this program is installed … | |
Re: [url=http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx]Linked lists[/url]. [url=http://en.wikipedia.org/wiki/Linked_lists]More linked lists[/url]. | |
Re: >char c; c should be an int, because that's the type that fgetc returns. Specifically, EOF may not be handled properly and certain values may overflow a char. You should also limit the scope of your variables as much as possible. I'd write it more like this: [code=c] #include <stdio.h> … | |
Re: >I was wondering if there are any differences between the Win32 API talked about in >this book and the one that applies to Vista or anything newer than Windows 2000. I'd be surprised if there aren't. The API is constantly evolving, but the stuff covered in your book is still … | |
Re: >What is c_str() doing? Why don't you read a C++ reference and find out? | |
Re: >I don't know enough about C++ or Java to really understand an >appropriate situation of why one would use one over the other C++ is well suited for back-end stuff, Java handles everything else. By "back-end stuff" I mean things like the JVM itself. >I just talked with an individual … | |
Re: >May I know "Candy" is on heap or stack? Probably neither, and it doesn't matter as the compiler manages the memory for string literals. Trying to delete memory that you didn't explicitly allocate would be most unwise. | |
Re: >Is that considered "wrong" or weird? Falling off the end of a function automatically returns, so it's weird in that people don't expect to see that kind of redundancy in well written code. It's not wrong though. | |
Re: >Is there anyway to make %s ignore whitespace? No, but you can use a scanset to get a little more control. For example, to read an entire line with fscanf you could do this: [code=c] char buffer[100]; fscanf ( file, "%99[^\n]", buffer ); [/code] However, in your case, selecting which … | |
Re: For starters, why are you using goto instead of a simple loop? >it goes back to the main loop and continually loops! It works for me. Please provide exact steps during execution to reproduce the problem. | |
Re: >I am wondering how one would append additional memory >to the end of a pointer that already has memory allocated? Assuming one can't use a container class that handles memory for you, realloc doesn't have a C++ alternative, so you're stuck doing it manually. Here are the steps: 1) Allocate … | |
Re: >My question is how to acess these elements Looks like an obtuse way to intialize a multidimensional array: [code=c] #include <stdio.h> #define X {{1,1,2,3,4,5,66},{3,2,4,1,5,0}} #define F {{1,2,3,4,5,6,7},{1,2,3,4,5,6}} #define I {{5,6,7,5,4,3,2},{0,9,8,7,6,5}} #define Y {X,F,I} int main ( void ) { int a[3][2][7] = Y; int i, j, m; for ( i … |
The End.