2,827 Posted Topics
Re: [code] infile >> value; while (!infile.eof()) { outfile << value; outfile << endl; infile >> value; } [/code] You have [ICODE]infile >>[/ICODE] reading one number per trip per the loop, plus once at the top. If you have this file: [code] 7.8 7.6 8.9 [/code] how many trips through the … | |
Re: [QUOTE=new programer;1017463]Howdy Folks! I've been asked to write a program that reads in an interger N and calculates The factorial ... I wrote this yesterday but it does not seem to work .. here's the code : [CODE] #include <iostream> using namespace std; int main() { int i=0; int s=1; … | |
Re: Any casting you do to get this to work will just be a band-aid to cover up a problem. This program doesn't need any casts. Lines 63 and 64 appear to me to be impossible to reach. Line 22 - season is uninitialized, but you use it in a comparison … | |
Re: You don't need to copy anything to get a row. You just need a pointer. The program below reserves space for and initializes 12 integers. Row 2 is integer indexes 8 through 11. "Copying" implies changing the memory at certain locations. That isn't necessary here. The row2 array simply points … | |
Everyone has way less than before, except for newbies, who appear to have the same. I remember Ancient Dragon starting a thread requesting a way that he could possibly neg rep someone without placing them in an eternal red zone. Makes sense. Everyone deserves to make a mistake and learn … | |
Re: [QUOTE=reverence;1014461]just newbie here and am trying to learn some of this regarding to my course aa minor in com sci. ..[/QUOTE] "Community Introductions" would be the proper forum for posts like this. Welcome! | |
Re: Please repost the expected and actual output in code tags. All spacing gets stripped out otherwise so we don't know if that happened here. I suspect so because neither figure looks like a diamond. The expected output looks like a half-diamond. Is that what you want? | |
Re: [QUOTE=Artamos;1013687]First my skill levels: I was over the moon when a friend donated his Trash80 to me, complete with manuals, oh so many years ago.. I got a glimpse into the PC world and later embraced DOS programming..:) As windows came into the picture I left behind my 'boyhood' knowledge … | |
I've googled this and it looks to me like what I am trying to do is impossible. I'm trying to write a [ICODE]Display[/ICODE]function that can take different parameters and call the appropriate function based on those parameters (i.e. function overloading). I've read that C doesn't allow this, but I figured … | |
Re: This isn't a code snippet, this isn't C++, get rid of the HTML code, and this is way too much code for someone to go through without a much more precise pinpointing of the problem by you. [LIST=1] [*]Post in the correct forum. [*]Post as a regular thread rather than … | |
Re: There's more than one way of splitting it up. Here are two of them: [code=text] 1->2->3->4->5->6->7->8 becomes 1->2->3->4 and 5->6->7->8 or 1->3->5->7 and 2->4->6->8 [/code] The first way requires you to know how many elements you have in the first list before splitting the list. Go through half of them, … | |
Re: Here's a code snippet I wrote a while back that you might find useful. It isn't the only way to do it, but it has a nested loop and takes advantage of some efficiencies such as not testing 4, 6, 8, ... as the previous poster mentions. Nor will it … | |
Re: If you need help, then this isn't a code snippet. Please post as a regular thread. | |
Re: [QUOTE=NICEGUY123;1012835]I need some help passing a array of integers into a hash table by chaining. So if the array is filled it that location it will go to a linked list of the index. any ideas on how to get this done. This is what i have so far. [CODE]chainFunc(int … | |
Re: You isolate a character int a string using the [] operator. [code] string input = "yes"; char firstLetter = input[0]; if (firstLetter == 'y' || firstLetter == 'Y' || firstLetter == 'n' || firstLetter = 'N') cout << "Input is valid\n"; else cout << "Input is invalid.\n";[/code] | |
Re: I've never heard of "rt" mode. Are you sure you didn't intend the mode to be "r+"? Check errno and see what the problem is. Here's the man page for fopen. I see no "rt" option on it. It also has the possible error flags. [url]http://www.manpagez.com/man/3/fopen/[/url] But since you're using … | |
Re: Since you haven't provided the printInfo function, we can't see whether anything is wrong with it. My first advice would be to just have printInfo () display "Hello World" and return. If you don't get that output, then it's not even being called and that narrows down your problem. If … | |
Re: You call srand ONCE during each program, then you call rand to generate the numbers. If you want ten numbers, call srand (time(0)) once at the very beginning of the program, then call rand () ten times: [code] srand (time (0)); // first line of program for (int i = … | |
Re: I'm not a Windows programmer, so I can't help debug, but is there anything in the program that requires you to use all of these Windows-specific headers? Will the regular C and C++ standard libraries not do what you need? I'm pretty sure nothing but Visual Studio uses "stdafx.h", and … | |
Re: [QUOTE=ayeshawzd;1009927]now u can try n no thanks needs[/QUOTE] [LIST=1] [*]Post has nothing to do with the thread. [*]Original poster has shown no effort, so you shouldn't be fixing the code from another poster, even if you were posting on the correct thread, which, again, you are not. [*]No code tags. … | |
Re: This isn't a code snippet. If possible, please change the thread type to a regular old thread as opposed to a code snippet. The && operator doesn't work that way. You want something like this: [code] if (a > b && a > c) cout << "First value is the … | |
Re: In addition to post 2, you still have problems. I'm not entirely sure what they are, but if x1, x2, y1, y2, z1, and z2 are supposed to be the same values at the end of the first function as they are at the end of the second function, they … | |
Re: I don't know what you're doing with the posts, but preview them before you post. You have some odd tags. Perhaps you pasted html code rather than plain text code and pasted it here. Hit "Preview Post" to make sure things look right, then fix the post if there's something … | |
Re: The compiler doesn't like the fact that you are initializing this array between lines 10 and 47. It wants you to do the initialization after line 47. Is this a static array? If not, you may want to initialize it in the constructor. Anyway, check out this link. I don't … | |
Re: There are a lot of problems with both the algorithm and the program's implementation of the algorithm. Let's start with primes[]. What should primes[] eventually contain if I enter a max of 25? Is primes[] supposed to contain all prime numbers less than 25? The first 25 prime numbers? Regardless, … | |
Re: Sounds like there is a lot of math involved. If you refer to a theorem, you should link it: [url]http://en.wikipedia.org/wiki/Separating_axis_theorem[/url] Is this a math problem or a problem with the implementation of the math in Java (i.e. do you understand the theorem and know how to use it successfully, but … | |
Re: One, it's [ICODE]int main ()[/ICODE], not [ICODE]void main ()[/ICODE]. Two, we need an input file. Three, what's the point of having a program with no output, either to the screen or to a file? How do you test it? If there is output, I missed it. Four, what's the question? | |
![]() | Re: [QUOTE=vs49688;1007243]Hey, Does anybody know of a way to generate a random number without using srand(time(NULL)). I need it for a program I'm writing. srand(time(NULL)) is seeding it based on the computer's clock, but it's only accurate to the nearest second, so it's not fast enough. I've had to put Sleep(1000) … |
Re: [QUOTE=NinjaLink;1005026]This is the latest code that I have to duplicate 4 words in my list. I am currently experiencing "base operand of '->' is not a pointer errors", and I can't figure out how to fix it. Am I going in the right direction in duplicating 4 words in my … | |
Re: [QUOTE=Deva.VG;1007230]Can I get the java code for online transaction to embed it with the webpages[/QUOTE] We understand that you're an important person and you have a busy life and you thus have neither the desire nor the time to put effort into this, but please realize that you have to … | |
Re: Try setting your Pawn panels to a background color of green or something and see if anything that's displayed ends up being that color. If it isn't displayed, it can't be clicked. You have this line: [code] new Pawn(); [/code] which creates Pawn objects, but these objects never get displayed? … | |
Re: You need to post more code. We need to see the declaration of mGPA. Presumably it's a double, float, long, int, something like that, so when you enter "x", >> can't do anything with it and it has this "x" in the stream that it must get past before it … | |
Re: Ancient Dragon already explained the way it works here in your last thread. Post some code (in code tags) that shows you've made an attempt, then ask a SPECIFIC question: | |
Re: Your comment in line 7 is revealing. It says that the ending bracket ends the function isAlive (). It does not. It ends the if-else statement. You need ANOTHER ending bracket after that to end the isAlive () function. Right now you have your toString () function INSIDE of your … | |
Re: Line 29 won't work. getline reads a line, so you should have this (no = sign): [code] getline (cin, line); [/code] If you then want to convert line into an integer, use atoi or strtol. These work on C-style strings, not C++ style strings, so convert line using c_str (); … | |
Re: [url]http://www.daniweb.com/forums/thread227475.html[/url] | |
Re: Lines 99 - 129 - This looks like an infinite loop to me if you enter "-1". Lines 101 to 119 are skipped since "-1" isn't 10 characters long. The "if" condition in line 122 isn't true since accountNumber is "-1". What code do you want to execute if accountNumber … | |
Re: [QUOTE=whiteyoh;1005394]Hi All, I have an array of 3 objects stored in cdList. Because I have now added them to an array, the usual method of displaying no longer works: [code]System.out.println(cd1.getArtist() + " " + cd1.getTitle() + " " + cd1.getCost());[/code] My questions are...... how would i amend to output the … | |
Re: Define "value". Your CD class doesn't have a data member called "value". It has "Cost". Is that "value"? If you're adding up all the Costs, you can have a static variable in your CD class. You can also have one for the number of CD's. Something like this: [code=JAVA] public … | |
Re: Having a static Collection of CD objects is fine and will work, but I see nothing in your requirements that would need more than I posted in my post in your last thread (a static integer and a static double, adjusted during each call to the constructor). Did you run … | |
Re: [QUOTE=trac15;1004282]Thank you! But the write function doesn't seem to work or i am going in the wrong direction. can u help me[/QUOTE] Post poly.h and poly::write (). We have no idea what you might be doing wrong unless you post the code. ![]() | |
Re: Repost in code tags: [noparse] [code=JAVA] // code goes here [/code] [/noparse] Without them, we can't see the indentation and we have no idea what lines 27 and 43 are. | |
Re: [code] *double getSales() [COLOR="Red"]is passed the name of a division[/COLOR]. It askes the user for a division's quarterly sales figure, validates the input, then returns it. It should be called once for each division. *void findHighest() [COLOR="Red"]is passed the four sales totals[/COLOR]. It determines which is the largest and prints … | |
Re: There are a few ways of calculating the standard deviation, some more efficient than others. Say you have five points: 1,2,3,4,5 Calculate the mean, which is 3. Now go through the points one at at time and get the differences: [code=text] 1 - 3 = -2 2 - 3 = … | |
Re: This program should really have some functions. You have a few tasks here: [LIST=1] [*]Display the options. [*]Ask the user for the the number of characters. [*]Ask the user for the option. [*]Make sure the person enters legal values for both. If not, give an error message and prompt the … | |
Re: One, use code tags: Two, what's the question? Three, don't use `void main ()` even if your compiler lets you get away with it. Use `int main ()`. | |
Re: There isn't too much to a boolean function. They return true or false based on whatever. Here's an example of a boolean function that returns true if both numbers passed to it are the same, false if they are different. You'll need to change it to accept the parameters you … | |
Re: [QUOTE=NicAx64;845977] Most of them are using Microsoft windows. And when I offer them a Knoppix CD they even refused to just boot from that live CD. and when I suggest them about a open source project instead of using visual C++ they totally refused .so now we are doing a … | |
Re: [QUOTE=virtualmisc;1003432]I want to find the product of two matrix using a function without using for loop? Help is really appreciated.[/QUOTE] Why don't you want to use a for-loop? That would be the easiest way. Any for-loop can be converted to a while or do-while loop, and vice versa. You're looking … | |
Re: [QUOTE=firstPerson;1003330]Not really a good idea.[/QUOTE] Why not? |
The End.