2,827 Posted Topics
Re: All your constructors are declaring local variables which immediately go out of scope. Hence you may as well delete them. Even if they weren't going out of scope and you used the class variables, they are immediately going out of scope(can't use array index 26 - valid indexes are 0 … | |
Re: I guess you need an algorithm to convert a tree node to an (x,y) coordinate based on the overall tree. The y is easy. That's just the depth of the node. The x is going to be harder. And what's really going to be hard is making sure everything doesn't … | |
Re: There are no hard and fast rules, but there are general guidelines. The overall theme is "give them what they need to do the job and no more than that". If they can't access it, they can't accidentally screw it up. They also don't ned to know or care about … | |
Re: There's no "wait" command in time.h. [url]http://www.cplusplus.com/reference/clibrary/ctime/[/url] Don't know where you found this, but it must have either been a user-defined function or another library was included. | |
Re: [QUOTE=Naqib;1512599]Hy welcom to all. I want to controll mini remote controll car from laptop. i have only experience of java desktop application. but no experience in wireless programming. what i do to complete this project thanks[/QUOTE] You'll need a remote that can be controlled via a laptop, presumably one that … | |
Re: First things first, get it to compile. Stick some return values in there, even if they're nonsense return values. Second, indent the code so it's readable. Third, find your missing brackets. That'll be much easier when you indent. | |
Re: Read the rules. No homework dumps. You need to post an attempt and ask a specific question. | |
Re: Use sizeof: [code] #include <iostream> using namespace std; int main() { cout << "int : " << sizeof(int) << endl; cout << "char : " << sizeof(char) << endl; cout << "float : " << sizeof(float) << endl; cout << "double : " << sizeof(double) << endl; cout << "long … | |
![]() | Re: Seems to me that if you want to catch bad input by player 1 you need another "else if" along these lines... [code] else if (playerOne == 'P' || playerOne == 'p')[/code] And the "else" should be an "invalid input" message. Right now "else" assumes player 1 entered something valid … |
Re: >> how do u use it How do you use what? Don't make us play 20 questions. If you have a question about Mike's answer, state the question. We don't know what "it" refers to. | |
Re: I don't see any char variables, so I presume you're trying to read a char into line 19, which asks for an int? The thread pinned to the top doesn't really address that issue. If you want to take characters, you'll need to read it into a string, check to … | |
Re: "sum" would imply adding. I see no addition operator (+) in your code. Hence no adding is done. | |
Re: Start debugging this function... [code] public int getAvrageSpeed(){ distance2 = (int) Math.sqrt(Math.pow(oldRandomX-randomX,2) + Math.pow(oldRandomY-randomY,2)); speed = (int) (distance2 / avrgTime); if((randomX <= xb && randomX+15 >= xb)&&(randomY <= yb && randomY+15 >= yb)){ avrg = (speed+avrg); avrgSpeed = avrg /zz; oldRandomX = randomX; oldRandomY =randomY; avrgTime=0.0; } return avrgSpeed; }[/code] … | |
Re: >> Even when n is quite large, it still returns 0. How large is large? I imagine if you had a million numbers, you could probably get a timing. A thousand might be too few. | |
Re: Is that the function declaration or the function call? If it's the call, get rid of the types(string, int). | |
Re: >> About your frogboy, i can tell you are a good human beings with a good soul From this thread, I judge frogboy to be a bad human being with a bad soul and Jon Karpinsky to be a good human being with a good soul. >> Far from it. … | |
Re: Sounds like you need`to do the "merge" part of a merge sort. Time to stick some debugging code in there. Lines 16 -21 added by me. Make sure the while loop functions as you think it should... [code] while ( e!=10 || f!=10); { if(array1[e].ave<array2[f].ave) { array3[g]=array1[e]; e=e+1; g=g+1; } … | |
Re: >> Run the program, it just says there's syntax errors. It either runs or there are syntax errors. If there are syntax errors, it won't compile, so it can't run. There could be a RUN-TIME error, but that's not a syntax error. What's the exact error message, what's the line … | |
Re: Just throwing something out here. Nine items in file, counter set to 10, the eof bit in the stream never being reset or checked, the file continuously being closed and reopened, and this: [quote] whereas when I type the last item number on the list, it can locate it [/quote] … | |
Re: You need a function that converts integers to a string. itoa, sprintf, or stringstreams are your best bet. itoa is non-standard, so you may have to write your own. This is C++. Stringstreams will do you just fine. This won't work... [code] board [i][j] =('0'-48)+(9*i + j+1); [/code] Too many … | |
Re: I'm unfamiliar with Windows programming, I've never seen the BYTE type, but presumably you can create a char* object containing everything and convert to a BYTE*, in which case you can use the standard cstring functions. [code] char buffer[100]; buffer[0] = 0; // not needed, but I tend to do … | |
Re: There's no way in hell I'm going to look at code with spacing like that. Get rid of the blank lines and add some indentation, etc. In addition, answer the question about whether we're dealing with anagrams or palindromes, tell us what the errors are, etc. | |
Re: So this is an idea for Daniweb? YouTube? Everywhere? Seems like an easy enough thing to implement. It's one more filter on a database query ("only show records from these users"). I like the idea. Or you can do it like everyone does it now. Link it to your Facebook … | |
Re: [QUOTE=tonyjv;]See the ranking of this newbie poster and compare it to statistics of the day for the site. Gives some thoughts about what kind of members the forum has. How about OpenID login without registration.[/QUOTE] I'm guessing we have an 850,000 way tie for spot 4,444. JamieLynnSEO, I just repped … | |
Re: Sort them first. 8,9,6,7,5,7,3,5,2,5,8,9 --> 2, 3, [COLOR="Red"]5, 5, 5[/COLOR], 6, 7, 7, 8, 8, 9, 9 Now that the list is sorted, you can take advantage of that fact, so there's no need for a counts[] array since you're only dealing with one number at a time and can … | |
Re: >> From line 15, it jumps to line 30. Significantly, all the tellg and seekg's happen BETWEEN lines 15 and 30. The file isn't opening correctly in the first place. Can't see how a file size would have any effect at all here. Perhaps write a small independent program that … | |
Re: That isn't the issue. I've added some debugging code in your loop so you can see what's going on. The displays may surprise you! [code] #include <iostream> using namespace std; int main() { int nDecimal = 0; cout << "Decilmal to Binary\nEnter the decimal value: "; cin >> nDecimal; int … | |
Re: They're sorting the list from high to low, then picking the first two elements, which are, since it's a sorted list, the largest two elements. Note that they don't use the 0 array index. Arrays start with element index 0 in C++, not 1. | |
Re: Check your spelling! [code] BinaryP[COLOR="Red"]re[/COLOR]mute[/code] | |
Re: I'm not sure I buy into this idea that if one provides code, they "deprive" or "ruin" anybody's thinking process. Maybe it's because I'm older, have already "been there, done that" as far as formal schooling goes, and I'm a professional programmer now. I've already proved myself and hence no … | |
Re: I'm surprised lines 3 and 12 display "a" actually. I'm wondering if it's dumb luck. I would expect the FIRST character printed to be 'a', but after that, since you have no null terminator, I'd say it's undefined behavior. Potentially you could just print stuff forever. char* is assumed to … | |
Re: >> it did nothing It did "nothing"? It should have at least displayed "Welcome to Word Jumble By Khoanyneosr!" Are you sure this compiled? If so, it did something. What did it do? | |
Re: >> come on Too pushy. >> I must submit it after tomorrow Not our problem. >> I don't have enough time Tough. If I was going to help you before, now I won't. >> please just give me the correction of my code Again, too pushy. Note that this post … | |
Re: Your class wouldn't be called incrementMinutes. It would be called Time or something similar. Presumably it would have hours, minutes, and seconds as its data members, and it would have a METHOD called incrementMinutes. [code] class Time { private: int hour; int minute; int second; public: Time(int hr, int min, … | |
Re: [code] volume=[COLOR="Red"](4/3)[/COLOR]*pi*pow(radius,3); [/code] Integer division. 4 / 3 is 1, not 1.333. Try replacing with floating point to avoid this problem. [code] volume=(4.0/3.0)*pi*pow(radius,3);[/code] | |
Re: 5 + 3 * 8 - 4 = 25 This is correct. 5 + 3 * 8 - 4 = 5 + (3 * 8) - 4 = 5 + 24 - 4 = (5 + 24) - 4 = 29 - 4 = 25. 12 / 3 * 4 … | |
Re: Just use an infinite loop. You already have the exit statement in there for when they quit, so you don't need a condition for the while statement. [code] while(true) { // stick everything that needs to repeated here }[/code] | |
Re: It's one of those things where you have to learn the mechanics of pointers first, then later you'll understand the wisdom. One always starts from easy to hard and the easy examples are almost always examples where you could just as easily do without them, so they don't make much … | |
Re: Not sure what the question is. If it's "How do I set up/add to a colection if I don't know the size?", you've already answered yourself: >> I thought i could search if it's already in the array/[COLOR="Red"]vector[/COLOR]. >> so i would have to include a [COLOR="Red"]expanding varible[/COLOR]. Vectors are … | |
Re: >> So i am assuming they are built into the EXE I doubt it. I've never heard of such a thing. An executable is just machine code, isn't it? | |
Re: Since it's already defined, you already have it, sort of. Just leave the keyword "string" out as well the inner brackets. [code] for (int x=1; x<3; x++) {MyArray[1][x]="-";} [/code] This is a 2-D string array? [EDIT] Actually, I think you have to fill in the "blah", "etcetera", and the declaration … | |
Re: I'd say that once someone posts something here, no one owns it anymore, or everyone owns it. You can't really say Daniweb owns them, because then I'd need to get Daniweb's permission to use my own code that I posted, which I clearly don't need. And anyone who decided to … | |
Re: [QUOTE=gnyderek;]it's a very simple program: payroll calculations for 5 employees. but how to do the count?[/QUOTE] How the hell should we know? | |
Re: [QUOTE=Taywin;]??? I don't see any equation like that above? Also, the value of 'money' would go sky rocket in one go ???[/QUOTE] Just ignore that post completely. It's ridiculous on so many levels. Then again, the OP deserves no better. With any luck, the OP will submit that line of … | |
Re: If the Army had wanted you to have an opinion, it would have issued you one. - Every drill instructor who has ever lived. | |
Re: I suggest removing all cin and cout statements from encrypt and decrypt. Those functions should be used to encrypt and decrypt. It should be other functions' job to provide encrypt and decrypt with data and decide what to do with it. Perhaps I would like to use your decrypt and … | |
Re: itoa isn't standard. I don't know why. But since it isn't standard, some compilers will have it, some won't. You can either find a compiler that has it, write your own, or use a standard function like sprintf. I suggest going with options 2 or 3. | |
Re: cplusplus.com gives good descriptions of what each function does. exit "cleans up" upon exiting. abort doesn't. Good discussion here. [url]http://stackoverflow.com/questions/397075/what-is-the-difference-between-exit-and-abort[/url] | |
Re: [code] vector<[COLOR="Red"]Term[/COLOR]> term; [/code] [code] [COLOR="Red"]string[/COLOR] userWord; myDictionary.term.push_back(userWord); [/code] See red. These need to match. You have a vector of Term. Push a Term, not a string. Try this. [code] Term aTerm; aTerm.word = userWord; aTerm.definition = userDefinition; myDictionary.term.push_back(aTerm);[/code] Now all the types match and the compiler should be happy. | |
Re: Things would go much much faster if the data was stored purely as binary data (i.e. the raw bytes) rather than as a text file. The tabs also screw everything up. If it was the bytes themselves, you'd just use fread from cstdio and read thousands of bytes at a … |
The End.