6,741 Posted Topics
Re: >I don't know exactly what your professor gave you Probably something akin to bad Java via C++. Professors have a tendency to do that. :rolleyes: | |
Re: The only way your post could be less coherent is if you used l33t speak. :rolleyes: | |
Re: [code]#include <cstdio> std::sprintf ( y, "%d", x ); [/code] | |
Re: >Trace the Partition function on the following array What's the function? There are several ways of partitioning an array, and each algorithm would have a different execution trace. | |
Re: >problem is how to implement, say a linked list in Python, since it doesn't have >pointers, or even static types so how this could be implemented is pretty unclear to me Python is kind of screwy if you're used to a strongly typed language like C++ (or even C!). To … | |
Re: If you have a new question, start a new thread. Since you seem to have solved your old problem, I'm locking this thread. Let me know if I've done so in error. | |
Re: >i need to have some application of the priority queue Homework? Read our rules, please. Not homework? Use your imagination. It's not terribly difficult to think of applications for a priority queue if you know what one is. >thanks but i just need the applications of the priority queue This … | |
Re: >is it possible to declare constructors as private? Yes, and it provides some valuable functionality to do so occasionally. >if yes, will some one explain me how to do it Just place the constructor declaration in the private section rather than the public section: [code]class test { public: test ( … | |
Re: Could you be more specific when you say "relationship"? That's a really broad term. | |
Re: >I'll write it off as another quirk in VC++6.0 and go with what I have. Yes, it's a bug. Get a new compiler. You'll eventually get tired of the endless limitations, and the workarounds required to write anything but trivial C++. | |
Re: You compare the contents of two strings with the strcmp function in the <string.h> header. What you're actually doing with the == operator is comparing two memory addresses. Since the two strings are extremely unlikely to be located at the same address, your comparison will fail and the sort will … | |
Re: First, format your code so that it's readable. Then post the code using code tags so that the formatting isn't lost. Finally, give way more information than "it doesn't work" and "seg fault". Despite how it may seem, we're not here to be your testers and debuggers. Please consider that … | |
Re: >i think so the program is perfect Then you're not qualified to help. The code is *horrible* in so many ways. However, because I'm pressed for time, I'll refrain from describing all of the problems in detail and focus only on the search function. >booknum = &i; What's this? >if(temp->booknum … | |
Re: >it has to print the grid like this and im havin trouble with the formatting Do you need to print the grid as well as the array contents? If so, it takes a smidge more work. :) [code]for ( i = 0; i < limit; i++ ) { /* Print … | |
Re: >i want to know everything abt container classes. Ooh, me too. Start by learning how to use them with books that focus on the standard library and references that inform you of their capabilities. Then learn their limitations through experience and asking lots of questions. Finally, attempt to implement them … | |
Re: [code]next_char: mov al,message[ebx] mov result[ebx],al add al,32h[/code] Watch your order of operations. You save the character to al, then copy al to the result string, *then* modify al. Also, if you're converting an ASCII letter to upper case, you need to subtract because the upper case letters are less in … | |
Re: >I am not really a beginner looking for some to teach me from scratch. Then why is this forum inadequate? If you don't need to learn from scratch then you really are better off teaching yourself and asking for help when you get stumped. It saves you the money and … | |
Re: Let's say you have a list of 40 people. You can pick a random one and then mark it as chosen (somehow): [code]for ( int i = 0; i < n; i++ ) { int r; do r = rand() % 40; while ( list[r].chosen ); list[r].chosen = true; } … | |
Re: >I need to find out if the length of the integer (string) is less than 5 digits. Um... [code]if ( s.length() >= 5 ) { // Proceed } [/code] | |
Re: >Graph theory (vertex-edge) is one of popular projects for uni. >students, here is a link which includes source code and explains. This is borderline on breaking the rules, but I won't remove the link because it doesn't *quite* cross the line. Keep in mind that if a post stinks of … | |
Re: >how can you read a hexadecimal number in c++? is there any option with cin/ The std::hex modifier works with input streams: [code]#include <iostream> int main() { int x; std::cin>> std::hex >> x; std::cout<< x <<'\n'; }[/code] Type in 1B (or 1b), and the output will be 27, which is … | |
Re: >Was just working on detecting memory leaks Programmatically or are you just working on setting up guidelines? >Where can i get the actual code implemention of new and delete functions in C++ Wait, what? This varies with every implementation, and the internal mechanism should be largely irrelevant even for a … | |
Re: >anybody here?!! Yes, but let me make it clear that just because you ask a question, it doesn't mean you're entitled to an answer. We're all volunteers here, and we aren't obliged to help you if we don't want to. Bumping your thread on the assumption that you deserve an … | |
Re: >either unconditionally or after testing the result of "CMP: instruction.. Or any instruction that modifies the appropriate flags. For example, I could say: [code]dec ecx jz foo [/code] To jump to foo when ecx reaches 0. Sometimes it's more efficient to avoid cmp in favor of a more implicit test. … | |
Re: >I have a class called anItem which is defined something like this I'll assume it's "something" like that rather than exactly like that because that class won't compile (no trailing semicolon) and even if it did would be unusable because all of the data members are private with no way … | |
Re: [code]normalXPrecedence["x"] = 1; normalXPrecedence["x^2"] = 2; normalXPrecedence["x^3"] = 3; normalXPrecedence["x^4"] = 4; normalXPrecedence["x^5"] = 5; normalXPrecedence["x^6"] = 6;[/code] Are these lines actually in the global scope, or are you summarizing by removing the function that they reside in? Only declarations and definitions are allowed in the global scope, and assignment … | |
Re: [code]float mean(const double data[][3], int rows, int columns);[/code] Yes, you must specify all but the first dimension, though if you want to include the size of the first dimension as well, that's okay too. | |
Re: >what exactly is segmentation fault or access violation and exactly when does it occur? A segmentation fault is when you access memory outside of your address space and the OS politely asks you not to do that. >Why does the following program work correctly Undefined behavior can do anything, including … | |
Re: >Is this concept flawed? No, that's a good way to do it. Create a class that wraps the types you want and supports sorting on the fields you want, then create a container of objects of that class. | |
Re: Just use what you're familiar with on Turbo C++. If Dev-C++ complains about a header, remove the .h suffix, and place "using namespace std;" after your headers. That should take care of most of your immediate issues. ![]() | |
Re: >while ((ch = getchar()) != NULL && ch != '\n') NULL is not the same as EOF, and it never will be. Also, ch should be declared as int because char might be unsigned and EOF is a negative value. >If there's some kind of space saving technique please let … | |
Re: >why then is it apparently ok to mix C with C++. If C++ supports the features then the only problem is with stuffy people who think that C++ should be pure...for some skewed definition of "pure". :rolleyes: For example, C-style strings are perfectly acceptable to the C++ standard. There's nothing … ![]() | |
Re: >İ dont know anything about file IO That's nice, so what are you going to do about it? If you said "Post to Daniweb and hope someone does my homework for me", you get a slap on the wrist. If you said "Open my book and try to figure it … | |
Re: >Which of the following dynamically allocates an object of type ourClass? e, none of the above. >In the second line, which version of mem() is accessed? c, this code causes an error. | |
Re: You only need to declare a function as virtual at the highest level. Any child classes will implicitly declare the same function as virtual, so there's no need for an explicit declaration, but it never hurts to be explicit. So b is the required answer and a is optional. | |
Re: That's a non-trivial program that involves working with the different image file formats (wotsit.org is your friend) and drawing them accordingly using a non-standard graphics library. As such, your question is far too broad for us to help with. Be more specific. | |
Re: >1) I do not know how to start/initiate my data upload to the PC First you need to have a clear idea of what 'upload' means to you. Are you gathering the data on another system and transferring it through a network to the PC? Are you reading from a … | |
Re: Please reply to your existing thread rather than start a new one with *no context* at all. By the way, this thread will be locked so you're encouraged to follow my advice. | |
Re: The XOR operator is usually used to flip bits. You can flip a single bit by making a 1-bit mask (shifting 1 to the proper bit position) and then XORing the value with your mask: [code]inline unsigned flip ( unsigned x, unsigned bit ) { return x ^ (1UL << … | |
Re: There's no reason to use ungetc in that program. Can you be more specific about the question, because it sounds like information is being lost in translation. | |
Re: >I would like to know whether the dynamic memory pointer is still >available even after freeing the allocated memory. No, it's not. When you free memory, you must reassign the pointer to memory that you own before you can dereference it again. | |
Re: >Shall i dowload this MASM free? [url=http://www.masm32.com/]masm32[/url] is pretty good from what I hear. I only have a passing familiarity with the syntax, but my understanding is that the macros are exceptionally powerful. If you like that sort of thing. Since you have experience, that might be your best bet. … | |
Re: >please check it and give me suggestion. Um...no. We're not going to error check your homework for you; that's your job. If you have a specific problem or question, we'll be happy to assist. | |
Re: >Can you still use BIOS functions win 32 bit programs? No, the BIOS and DOS interrupts are strictly 16-bit, so a 32-bit program cannot use them. However, if you write a 16-bit program you can use them to a certain extent, but I would question why you need to on … | |
Re: >idon't know how to get the ASCII of any number or character char is a little int, so you don't need to do anything special to get the numeric value of the character (ASCII isn't always used). However, since ASCII isn't always used, and not all character sets are required … | |
Re: Don't play around with casting like that unless you know what you're doing. Type punning can be tricky business, but barring transmission issues with your sockets, this should work: [code] #include <cstring> #include <iostream> using namespace std; int main() { int i1 = 12345; char buffer[sizeof ( int )]; memcpy … | |
Re: >can i use strtok to token the string Not without first copying the string to an array. The c_str member function gives you a pointer to const char, and strtok modifies the string you pass to it. To do it right, you would end up with something like this: [code]char … | |
Re: >Any help you guys can offer would be helpful. My first bit of help would be to tell you to use code tags, not inlinecode tags. >sort them so that the names are in ascending order based on the average "Them" being the 3 numbers for each name or the … | |
Re: >I'm not too sure about 2d vectors although I guess its inherent structure would probably be the same. [code] std::vector<std::vector<T> > matrix; [/code] std::vector is designed to work the way people expect even in multiple dimensions. |
The End.