1,362 Posted Topics
Re: You don't need a for loop to display the single value user wants. Simply test if the input value i is between 0 and size-1, inclusive. If so, display the array element at that index. You should wrap all this in a loop that continues as long as the input … | |
Re: 14 right. I was halfway expecting the solution to be all Falwell/Robertson. Scary people on both sides. | |
Re: [quote]my problem right now is i cant get to calculate m correctly. heres the code i wrote so far. i know my code is cluttered and could be cleaned up but right now i just want the program to work.[/quote] Please explain how m is to be computed. It looks … | |
Re: Cool? yes. Technologically interesting and challenging? yes. Does it do a darn thing to make a computer more useful? Hardly. Most of that demo shows effects that are eye candy and fluff, but do nothing for usability - they are big time and resource wasters. Do you really want to … | |
Re: Don't put data types with your arguments, where you are calling the functions. Just the argument variables. For that matter, why are you passing parameter [icode]input[/icode] to the functions, if the input action is done in them? As you have them structured, all your functions need is the conversion rate. | |
Re: Sounds like GBR is getting really wimpy on what they'll let in. Many years ago a club DJ friend spent over a week continually playing records - the bar was "open" 24 hours a day during this feat (only served non-alcoholic stuff during non-legal hours), logs were kept of witnesses, … | |
Re: You need some additional condition to know when you've replaced an 'o', and make the loops quit. If this action is the sole content of a function, this might be one good case to just return immediately upon doing the change. | |
Re: [QUOTE=ivailosp;583446]forced to use only one return in a function- lol that's new for me :][/QUOTE] Come to my class sometime! I teach that generally, the loop condition controls when the loop ends, exiting prematurely should be for exceptions. As AD said, one way into the function, one way out - … | |
Re: If you want your output operator to output the data in rows and columns, you'll need nested looping to do that, or at means of knowing when you've output "column" number of elements, then output and endline, and reset that counter, if needed. I don't anything in the input overload … | |
Re: [QUOTE=jwenting;557229] For those of you with bad eyes :) here's a bigger view of the aircraft I showed earlier that noone has yet identified: [url]http://hornet.demon.nl/Dscn1451.html[/url] Double points if you know what the aircraft with tail number "46" is that you can only see the tail and exhaust of (tip, you … | |
Re: The problem, while exhibiting itself when the destructor is called, is not actually in the destructor. Your Copy function makes a shallow copy - in your code object "a" points to the same memory as object "integer". When the first of those gets destroyed at program exit, the pointed to … | |
Re: You know how to pass the value to be tested to you function, right? And how to return true or false? So your middle part is how to determine if the tested value is a vowel. The vowels are a,e,i,o,u (and sometimes y). Compare to those characters (probably both the … | |
Re: For starters, your private members should include the row and column sizes. Thus, your overloaded ( ) operator would compute the actual index, using something similar to what you commented out in your constructor above [icode] index = desired_row * columns + desired_column;[/icode] | |
Re: First, please spend a bit of money on some indenting, it's cheap. Simple solution is to allocate single record object. Input to it, then assign it to the next spot in the array. [code=c++] //after line 21 record temp; //replace line 42 & 44 cin >> temp.name; cin >> temp.number; … | |
Re: [QUOTE=jwenting;582028]On the first pull of the trigger, there's indeed a 50% chance. There's either a bullet there or there's not. Of course depending on the gun the chance of getting shot might be 100% as some guns have a mechanism that skips empty chambers :) On the second pull, there's … | |
Re: The pointer is not needed. Perhaps this code is simply a means to demonstrate how you might access the data either via its array element or a pointer to an element. For example, lines 21-23 might also be written as: [code] strcpy( Candies[0].brand , "Mocha Munch" ); //see below Candies[0].weight … | |
Re: If your problem is to display the number of votes each candidate got, you'll use a loop similar to your input loop, only output each element of the candidate array. If you want to only show which candidate won (got the most votes), you'll have to go through the candidate … | |
Re: [QUOTE=ivailosp;580914]double fntArray[count]; work in gcc[/QUOTE] Yes, because the gcc people are getting ahead of themselves. That usage has been adopted for C, but has yet to be actually incorporated in the C++ standard, as I understand it all. So such use is not going to be portable for some time … | |
Re: What is this [b]really[/b] doing? [icode] for (loop = 0; loop > 5; loop++)[/icode] | |
Re: Type float has less precision than double ( 7 digits versus 15). There is a long double type, but it varies among compilers/operating systems as to how much more precision you'll get ( no more at all on Visual C++, typically it's a 10 or 12 byte value on others. … | |
Re: Because your account file variable (used in the open function) is not a valid string? | |
Re: To get random values in some range, use the modulus operator as a means to limit the final value. | |
Re: In main( ), you have a value lowest and a pointer to it, lowptr. Your function dropLowest( ) takes a parameter by value, to which you store the lowest found value, and return that. Back in main( ), you do not capture that returned value, so it's lost (the dropped … | |
Re: First, your function names seem backwards - typically input means reading from file, output is to write to the file. That said, to attack your problem you need your file reading function to store to an array of your struct type. Once stored, in a search function you ask the … | |
Re: What's wrong with this bit: [code] getValues(n,lg,dataok); while(!(dataok=false)) { [/code] Once you figure that out, you really need to go back and revisit your logic for the loop. The dataok variable looks to be doing two different jobs - somehow telling me the input values are ok to use, and … | |
Re: [QUOTE=jwenting;570635]A car can be any colour as long as its blue...[/QUOTE] I believe Henry Ford said, "You can have your car in any color you want, as long as that color is black." My favorite car I've owned was a '69 Porche 911 (with a 1970 engine). All you had … | |
Re: I can see several possible problem areas. First, you're reading in to type char, which is a signed type. What will it do with values over +127? Second, some of those values may be 0. When you do the assignment from the char array to the string, it only copies … | |
Re: [quote]6. Language and culture will forever be different and major advances in science and medicine will change how we view the world.[/quote] Hmm, hasn't that been happening since July 7, 1947? | |
Re: Assuming you have a declaration for [icode]char * newptr;[/icode] your handling of the pointer arrays looks correct, as far as that goes. There are other problems or questions: First clarify, is the data in the form you show in example ( fn ln s1 s2 s3 s4) or as in … | |
Re: Are you sure you have this file in a plain console application project? | |
Re: In short, you probably want to detect the WM_KEYDOWN message from the spacebar, and until you see the WM_KEYUP from spacebar, process other key messages. | |
Re: It's not a C++ issue, it's your operating system that doles out CPU time to the program. It sounds like yours is a pretty compute-intensive app, so it will take a lot of CPU time. Is your Linux/Windows disparity on the same machine (dual boot) or are you testing on … | |
Re: fin.close( ); fin.clear( ); fin.open( "yourfile.txt); | |
Re: [QUOTE=jwenting;573441]Godaddy is a large hosting company.[/QUOTE] More importanly, it's a domain registrar - one of the biggest these days. So big, they put an ad in the SuperBowl. And get a lot of notoriety for creating ads too scandalous to be aired (so they say, anyway). | |
Re: Sit back an analyze what you're trying to do. It looks like your assignment is to count how many even numbers occur between num1 and num2. Is that count to also include num1 and/or num2 if they are even? num1 and num2 should be the starting and ending points of … | |
Re: You have functions that return values, yet you don't capture or use those in main( ). You are probably always computing the day that the random value in memory that G points to equates to. Garbage In, Garbage Out | |
Re: Please read the "Read this before posting" at the top of this forum. Short version - have you looked for an answer? What have you written already? What does it do or not do? You'll get help here, when you've shown that you are actually trying to solve your problem … | |
Re: Here's a little demo showing how t copy the string into the array. It does not account for string length, but simply demonstrates how you might start this process. [code] #include <iostream> #include <string> using namespace std; int main( ) { string text = "Encryption"; char b1[4][4]; size_t len = … | |
Re: You are missing counting the 1-0 combination. Your main matrix defiition does not agree with your comment about it: [code]int matrix[10000][5] = {0}; //Define a matrix with a maximum of 100 rows and 6 columns [/code] is really 10,000 rows by 5 columns. This is one of the problems with … | |
Re: Are you in fact passing arguments to the program when you run it? It works ok for me, other than printing characters other than what's specified for the diamond's inner body and edge. Why all the use of pointers and address operators, when it looks like all function parameters should … | |
Re: And the number 1 thing wrong with it is that the test function returns TRUE for non-primes and FALSE for primes!!! Why the #define TRUE and FALSE when C++ has the perfectly good built in [icode]bool[/icode] type, with values [icode] true[/icode] and [icode]false[/icode]? ps - you're responding/reopening a three year … | |
Re: (AD, I'm hoping he means classmates) If your team members are not helping, I recommend a hardware approach - 3 foot 2x4 to their head or backside, whichever is softer.:twisted: I would get the data reading done, then the menu. Without data, it's hard to test the rest. From there, … | |
Re: In writing just one step of the formula, how can you relate the counter variable to what you see in the formula? | |
Re: When you enter a name longer than the input allows, the cin.getline( ) sets an error condition, so no further input will be processed. If you expect to handle overly long input, you need to follow it with a [code]cin.clear( ); //resets error flags cin.ignore( nn, '\n' ); //set nn … | |
Re: I'm not clear on what the problem is. Your code is reporting the depth of recursion on the variable x. Do you really want a count of how many recursive calls are made? If so, create the counter variable in the function as static, increment at the entrance to the … | |
Re: If you mean you are using variable names in other functions, that's no problem. The names will be only visible within the function in which declared. Look up "scope" in relation to C++ variables. | |
Re: You could approach this with a while loop, reading the name one time before the loop, then at the bottom of the loop [code] cout << "Programmed by Jim Johnson"; cout << endl << endl << "Type xxx for the name to Exit"; cout << endl << endl << "Enter … | |
Re: Are you putting the #define before all the #includes ? | |
Re: Could you expand on the problem statement a bit more? What do you mean by "structures similar to linked list" and the fact you store them in a multidimensional array? How many dimensions? If we're considering a 2D array, what does it mean to delete an element? I would think … | |
Re: You cannot print the whole array in one action. You cannot input a whole array in one action. There's really not much at all you can do with an array as a whole. You have to display it, element by element, in the same fashion as your input loop. |
The End.