6,741 Posted Topics
Re: Old threads are not automatically closed because there's no reason why the discussion could not be continued profitably by newcomers. We've discussed the issue of bumping before, and concluded that it's not enough of an issue to introduce such heavy handed methods. However, bumping is indeed frowned upon if the … | |
Re: [CODE]if(v.empty()) cout<< "v is empty!" <<endl;[/CODE] :icon_rolleyes: | |
Re: Go to Project -> Properties -> Linker -> System -> Subsystem and choose Console. | |
Re: [QUOTE]When I pass it to funct(&ue), I got the value of umsi correctly, but for the apn, I got the wrong value (seems like garbage).[/QUOTE] It [i]is[/i] garbage. In funct(), you're creating a new object of[ICODE] bts_pdn_con_t[/ICODE] and leaving it uninitialized. What you want to do, I suspect, is print … | |
Re: >i want my c++ program to display some Greek messages that i will define, but instead i get some garbage It works for me: [code] #include <iostream> int main() { std::cout<<" | |
| |
Re: [B]>*(T[j]).c_str()[/B] Check a [URL="http://en.cppreference.com/w/cpp/language/operator_precedence"]precedence table[/URL]. Member access has higher precedence than indirection, so you're still trying to call c_str() on a pointer. The arrow operator saves you from having to remember that rule though: [code] T[j]->c_str() [/code] | |
Re: [QUOTE=Chilton;1606630]Use a vector.[/QUOTE] "Without using an array" generally means "without storing all of the numbers", which means vector is out too. But even if you could store all of the numbers, doing so would be stupid because it's trivial to write a linear algorithm without wasting memory like that. | |
Re: We don't do homework here. If you want help, you'll need to provide more than just program requirements. | |
Re: [QUOTE]What happens when you set an int or double value to less than the minimum?[/QUOTE] Bad Things™. [QUOTE]I need my program to recognize when a number is smaller then the minimum, and then set the value to equal the minimum instead.[/QUOTE] Or you could just not let your value go … | |
Re: [QUOTE]Is C# better than ASP.net to download files automatically from the internet, update and retrieve information from databases (especially MySQL)??[/QUOTE] I think you're confused. What exactly are you trying to do? Yes, you want to download files and connect to a database, but for what purpose? | |
Re: [QUOTE]You can't. It's a static string and cannot be modified.[/QUOTE] Aroo? prose is an array initialized with a string literal, it can most certainly be modified. [QUOTE][B]>*ptr = *ptr-32;[/B][/QUOTE] Good god, are people [i]still[/i] doing this? The world is not ASCII anymore, folks, use toupper() if you want to be … | |
Re: The file format changed between Excel 2003 and Excel 2007. Your solution for the older format won't work on the newer format. How are you reading the files? | |
Re: [CODE]#include <iomanip> #include <iostream> using namespace std; namespace { const int MAX_ELEMENTS = 11; } int main() { // Step 1) Allocate the rows int **table = new int*[MAX_ELEMENTS]; // Step 2) Allocate the columns for (int i = 0; i < MAX_ELEMENTS; i++) table[i] = new int[MAX_ELEMENTS]; // Step … | |
Re: It's a myth. | |
Re: Change this [code] for(d=z; d>=1; d--) [/code] to this [code] for(d=x; d>x-z; d--) [/code] Now tell me why that works and what you were doing wrong. :) | |
Re: General discussions of security from a developer's perspective would fit in the Computer Science forum. | |
Re: [QUOTE]Don't use the standard libraries with the .h extension, they are out-dated (pre-1998) and are only kept around for backward compatibility[/QUOTE] Technically they're deprecated, but realistically that's a bluff. Even if the standard committee smokes a huge doobie and removes the old C headers in their stoned haze, compiler vendors … | |
Re: [QUOTE]For Vec a, i use "const" because a is never changed. Correct me if this is the wrong usage.[/QUOTE] a is passed by value, so you're already working with a copy. While it's not wrong to pass by const value, it's not very common. The reason I think your parameter … | |
Re: [QUOTE]Why is it a bad idea to use the std namespace for my new functions?[/QUOTE] If you mean something like this: [code] namespace std { // Add myfunction() to namespace std void myfunction(); } [/code] It's a bad idea because doing so invokes undefined behavior. If you mean something else, … | |
Re: Also note that the lambda return type can be deduced in this case, explicitly specifying it is unnecessary: [code] my_list.remove_if([](int x) { return x == 4; }); [/code] | |
Re: Four years of education doesn't buy you much, does it? You can't even think of a topic on your own. | |
Re: And your immediate problem is what, exactly? You neglected to actually ask a question. | |
Re: Not only is your example horribly broken, it's not even a valid example of the point you're trying to make. >void main() Implementation-defined behavior. main is required to return int. >printf("%d,%d,%d",i,i++,++i); Undefined behavior. The commas in an argument list do not constitute sequence points, and ++ modifies its operand. Undefined … | |
Re: [QUOTE]I typically make a Types.h to define all of my types in and then include that in all of my project files. I haven't ever seen this anywhere though, so I assume it is "bad/wrong".[/QUOTE] I do that occasionally as well, though that's not proof that it isn't "bad/wrong". ;) … | |
Re: For writing 1D barcodes without any special encoding, such as 3 of 9[1], you can download the appropriate font from [URL="http://www.idautomation.com/fonts/free/"]somewhere[/URL] and then simply draw the barcode on an image: [code] Bitmap DrawText(string value, string fontName, float size) { using (var font = new Font(fontName, size, FontStyle.Regular, GraphicsUnit.Point)) { var … | |
Re: [QUOTE=Aramant Coral;1604808]Graphic design.[/QUOTE] Defend your answer. | |
Re: [QUOTE]Is 2 a garbage value here?[/QUOTE] Yes. [QUOTE]Can anyone explain how 2 comes instead of a garbage value?[/QUOTE] If you're expecting something predictable for garbage, then your definition of "garbage" is badly flawed. | |
Re: >Is there anything better than this. No, not really. The question you should be asking yourself is why do you need this feature in the first place? [url=http://www.research.att.com/~bs/bs_faq2.html#no-derivation]Clicky[/url]. | |
Re: If you're taking two characters and turning them into the represented integer value, there's more to it than simply adding the two characters together: [code] #include <algorithm> #include <iostream> #include <iterator> #include <string> #include <vector> using namespace std; int main() { string code; cout << "Enter a code: "; if … | |
Re: [QUOTE]But caution: computer programming and drinking don't mix.[/QUOTE] False. My code while under the influence is the stuff of legends. The only drawback is that it rots quickly, like in a couple of hours or so. ;) | |
Re: We don't do homework here. Please make an attempt yourself if you want help. | |
Re: [QUOTE]Oh god here we go again. lol So what is C since technically I've only been using libraries/functions written in C.[/QUOTE] C is a programming language. :icon_rolleyes: It's a glorified text format which compilers use to convert conforming text files into the corresponding machine code for the targeted platform. | |
Re: [QUOTE]* How does stringstream work?[/QUOTE] That's a much deeper question than you probably think. But if you don't mind a heavily simplified code example, here's a simulation of stringstream: [code] #include <cstdio> #include <cstdlib> #include <ios> #include <iostream> #include <limits> #include <string> using namespace std; namespace jsw { class faux_stringstream … | |
Re: What makes you think there's a difference? Decimal vs. hexadecimal is a display representation, the underlying bits of corresponding values are unchanged. | |
Re: [QUOTE]I found a page saying that int a = 12; and int a (12); do the same thing.[/QUOTE] Indeed. There's also a third way in C++0x (where the added functionality prevents narrowing conversions): [code] int a{12}; // alternatively 'int a = {12};' [/code] [QUOTE]But is there something special with the … | |
Re: [QUOTE]Of all the errors I've seen for main() , this is the first time for this one...[/QUOTE] Sadly, not the first time for me. Usually the rationalization is that char is an integer type and the return values are all well within the range of char. | |
| |
Re: Let me get this straight. You have a final year project about a topic that was never covered in any way, shape, or form during the course? I strongly doubt that. It's more likely that you simply didn't pay attention and deserve to get a failing grade. | |
Re: Then print your command instead of trying to execute it and see where the differences lie between your manual command and the generated one. | |
Re: [QUOTE=DavidtheRaindog;1603385]Hi, I am writing an application in which I make a map of strategies keyed by a string symbol. In order to construct the strategies I pass the constructor a filename, out of which it reads out some data, into an initializing map. It is possible that some data might … | |
Re: [QUOTE]I've been wondering whether the C language can copy files from the internet into the user's device, and whether it can process web pages and databases or not..[/QUOTE] Yes to all of that. Check [URL="http://beej.us/guide/bgnet/"]Beej's guide[/URL] for socket programming to get an idea of how one would access internet data. … | |
Re: [QUOTE]thus iterators predefined functions?[/QUOTE] Iterators are a concept for range access with a design derived from pointers, where a concept is a set of requirements for accessing the range. For example, find() and for_each() can both be written with a minimal set of requirements (assumptions about the "pointer" type): [code] … | |
Re: The asterisk sets your field width to the corresponding argument. So the field width of the first number is the value of [ICODE]a[/ICODE] and the field width of the second number is the value of [ICODE]b[/ICODE]. Since that number of characters will be printed (with spaces for padding), printf() will … | |
Re: target and parent need to be references as well (or pointers to pointers) if you're using them as output parameters: [code] void find(string cod, tree_node* tree, tree_node*& target, tree_node*& parent, bool& found); [/code] | |
Re: [QUOTE]Is it mandatory to Use static functions for a Singleton class.[/QUOTE] It's not mandatory, but that's probably the most common implementation of the Singleton pattern. [QUOTE]But If you want to use it for production purpose[/QUOTE] Then I would ask why you think you need a Singleton. In my experience, they're … | |
Re: I know you asked about the conditional operator, but the following is a more conventional way of adding leading zeros to a fixed field width: [code] #include <iomanip> #include <iostream> using namespace std; int main() { short hour = 9; short minute = 10; short second = 5; char last_fill … | |
Re: I don't understand the question. Are you asking if reading from a stringstream is faster than reading from an fstream? | |
Re: Thread split from [URL="http://www.daniweb.com/community-center/geeks-lounge/threads/371508/1599249#post1599249"]here[/URL]. |
The End.