1,362 Posted Topics
Re: First, check your spelling. In line 26, you call function AddMatirix, which of course does not exist. Your function is written with two int parameters, i and j, which do not convey any information to the function, as written. Why not delete those parameters, declare loop variables in the function. … | |
Re: First, the code would be clearer if your variable names better expressed what they were. What's "total"? The input of distance driven should be "miles", not "mpg". [icode]mpg = miles / gallons[/icode] better expresses what you're doing. The calculation of the mpg for a given tankful should occur inside the … | |
Re: What's the largest value that can be stored in a long int? How does that limit compare to the value you're trying to stuff into a long int? | |
Re: [icode]results[0]= x * sin (x);[/icode] x is an array - it cannot be used as the operand of a multiplication nor as the argument to sin( ). Did you mean to say [icode]results[i]= x[i] * sin (x[i]);[/icode]? | |
Re: > [Only] one declaration of the variables are needed. Either before main() or inside of main(), doesn't really make a difference, but only once is needed. Actually, it does make a difference. The declaration outside of main( ) is globally visible and modifiable. This is generally to be avoided, especially … | |
Re: switch blocks are not good for doing range based decision making. You have to be able to do exact matches to integral types, which is often, as you surmise, way too much work. Use if...else if... construct to separate your data points into the appropriate range groups. | |
Re: Your new function, which still has the { } problem jonsca pointed out, will return immediately after the first number is read in, depending on whether it meets the 10-500 test or not. You should construct the loop to read in six times, and test if the new number is … | |
Re: I would do a search of the daniweb c++ forum and find this problem discussed many, many times. ( I wish profs would be a bit more creative and come up with some new assignments.) | |
Re: You need to write a couple of hand scoring functions. You don't look for all possible combinations, but look at a player's hand and determine what, if any, of the poker hands it constitutes. In evaluating a hand, you need to look at first the value of the cards, disregarding … | |
Re: To read just 5 characters at a time to your array, you could use getline( ). Make your array size 6 to allow for the null terminator at the end of a string, then [code] char arr[6]; //open your filestream as shown in previous posting while( infile.getline( arr, 6 ) … | |
Re: Visual C++ (other than the free express editions) can compile 64bit directly in the IDE. It does appear that you can compile from the Express edition, using command line compilation. See [URL="http://en.wikipedia.org/wiki/Microsoft_Windows_SDK"]here[/URL] | |
Re: And your question is? | |
Re: try [URL="http://go.microsoft.com/fwlink/?LinkId=51411&clcid=0x409"]here[/URL] | |
Re: What compiler/IDE are you using? That would help us to tell you where the input file should be located. Are you running this from the IDE or directly in a command window? | |
Re: [QUOTE=Ancient Dragon;529930] <snip> My suggestion to students is to ignore that warning message and use [icode]#pragma warning(disable: 4996)[/icode] to prevent the compiler from issuing it -- unless of course your teacher has instructed you to do otherwise.[/QUOTE] Or, follow the advice from M$ #define _CRT_SECURE_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE Use these #define's … | |
Re: Long time ago I used [URL="http://msdn.microsoft.com/en-us/magazine/dvdarchive/cc301454.aspx"]this article [/URL]as a reference to do such. Unfortunately, it seems the supporting code is not available at this time, from MS. But, if you Google for "imageview" you will find the code posted in a few places. I like Mr. DiLascia's disclaimer [quote] If … | |
Re: Here's your code, translated in to C++. [code] #include <fstream> #include <iostream> using namespace std; void READFile(char* filename) { int num; int color[100]; //make this large enough for any problem set int value[100]; ifstream inputfile; inputfile.open( filename ); if ( !inputfile ) { cout << "file not found, unable to … | |
Re: [QUOTE=pman182001;1017994]I need help with IT210 week 7 programming problems 1 and 2 pseudocode can any one give some advice?[/QUOTE] Read the problem thoroughly. List what you know, what's to be input, what you're to do with it. Then start listing the steps to accomplish the task. Voila, you're done. | |
Re: Read the full assignment. It should all be there. | |
Re: You could pass the username and password arrays (or the single array of user objects when you make a class) to the checkDetails( ) function. That way you don't have the arrays in global space (something we want to avoid) and the function will not be tied to any specific … | |
Re: I think a better approach would be just use getline to grab all of a line into a large string, then print out the first 22 characters that appear (or less if the line's not that long.) You can (with char array type strings) limit how much input getline will … | |
Re: [QUOTE=program900;1017134] A function called “menu” that displays a main menu. This function should return the choice of the user.[/QUOTE] So, your function must: 1. Display the menu. What are the options in this program? 2. Ask the user to make a selection from the options available. Usually you will take … | |
Re: Please read the sticky threads about how to ask questions. Mainly, please put your code inside code tags so it will be more readable, like [noparse][code] your code goes here [/code] [/noparse] Big problem with your second sample is that you must reset j back to 0 after its while … | |
Re: Please use this big white space to ask a question. If you read the sticky threads at top, you'll find useful information on how to ask questions here. It looks like you're writing in C, this is the C++ forum. | |
Re: What I believe the problem is asking you to do is set up the 2D array. Read in the temperatures along the edges (is the temperature the same all along an edge or does it vary along the edge, particularly near the corners?) Once the edges are initialized, begin processing … | |
Re: Is your array declared as 5 columns or as 6? It makes a difference in the indexing you use. Are you using the row index as the student ID? I don't see input for IDs. Remember that the maximum index you can (safely) use is one less than the size … | |
Re: Well, I think an elegant solution would be a loop that iterates from -4 to +4, inclusive. Within that loop is another that uses the absolute value of the loop counter to print out the numbers and stars. But, it must account for the extra instance of 1 and the … | |
Re: Why are you doing two input actions in the loop? The first, in the while condition, reads the word and stops at the newline. The getline will read and discard the newline, storing an empty string to your variable. The doubled up bob is being caused by your not putting … | |
Re: Depends on how easy you want to access the bits, and how you get the data. You could store the data as an unsigned char, and access each bit using masks. That easily handles single bytes. You could store the values 0 and 1 in an array of char or … | |
Re: Please read the sticky threads about using this forum, it'll make your time here more productive. Mainly, be sure to put your code inside code tags. This will make it more readable. When copying code from your text, be sure to copy it correctly. You have void Account::credit( int amount … | |
Re: Must have played it too much, dead link now. Sigh. Is [URL="http://www.transbuddha.com/mediaHolder.php?id=910"]this [/URL]the same thing? | |
Re: The error is due to the way floating point values are stored. Single precision, which it looks like you used, is only good to about 7 digits. Double precision will get you 15 digits. It's best to think of floating point values as approximations of the "real" value. See [URL="http://msdn.microsoft.com/en-us/library/47zceaw7%28VS.80%29.aspx"]here … | |
Re: A. You are responding to a three year old post B. You are hijacking that thread with a new problem C. You are asking for a solution to a problem you have not attempted to solve on your own D. This is a C++ forum, you're asking for a VB … | |
Re: You cannot define a function inside another function. So, your main( ) must be closed [icode] return 0 } [/icode] before you start the definition of makeChange( ) Your technique of multiplying by number of coins in a dollar is unusual, but seems sound. In removing that coin's worth from … | |
Re: That email link is a third party service, it simply forwards email independent of a mail service. Hmm, might be handy. To contact a DaniWeb member, click on their name in the upper left of the post and you'll get an option to send a private message, via DaniWeb. | |
Re: I think it has to do with the declarations of the items [code] Product milk = Product( "Milk", 7 , "Lot's of calcium"); [/code] Left side of the assignment operator creates the object. Right side of the assignment operator creates a temporary instance of the object, which gets assigned to … | |
Re: A little searching effort on your part will get results much faster than just shouting out questions to the world. [URL="http://lmgtfy.com/?q=differences+are+between+c+%26+c%2B%2B"]Try this[/URL] | |
Re: You're kidding, right? Is it April Fool's day already? Read the sticky posts - we don't do your work, but we'll be glad to help once you've shown a reasonable attempt on your own. | |
Re: As VernonDozier said, call srand( ) only once in a program. What happens, when you call it in the function as you did, and the function gets called repeatedly in a loop, the calls to srand( ) occur too quickly for the clock time to have changed, so you keep … | |
Re: I agree that your questions are valid, the little sample you provided is confusing. Could you post the whole of the main.cpp you were given, it might give us further clues as to what your prop expects. The only usage of line 5 I could imagine is if the class … | |
Re: Your smaller code compiled fine in VC++ 2008 Express, once I commented out the [icode]#include "stdafx.h"[/icode]. Similarly, commenting out stdafx.h and a couple other minor changes to allow compiling as console app rather than a windows app, ( _tmain to main, TCHAR to char) it compiled, with some warnings. So, … | |
Re: for the general search function, take the [icode] else return -1 [/icode] out of the for loop. That return statement should only execute if you complete the for loop and don't find the search value. [icode]int ary[][/icode] does not have a length member. You will have to pass the array … | |
Re: Do you mean to write a function that swaps two variables' values, and rounds to the nearest tens (not tenths, according to your example)? Or to just write code that does it in your main body? You'll use the same mechanism in either case. Do you know how to implement … | |
Re: If you know that the text file will be formatted EXACTLY as you show, then you can read and discard the first line (assuming the array size will not change). For the remaining lines, read and discard the first element, then read in numbers, discarding the commas. At its simplest, … | |
Re: Your second version is really not going to work - your swap portion only changes the assignment of the temporary pointers in the function, it does not change the ->next pointers in the actual nodes. More importantly, the return statement in the if block ends the function on the first … | |
Re: [code] for (i=1; i<=value; i++) { cout << "Enter some values: "; while (cin >> value) cin >> counter[i]; sum+= counter[i]; } middle = sum / value; [/code] Is this really what you mean to do? It doesn't make any sense. Did this even compile for you? (I don't think … | |
Re: Well, duh, we're here! 52 You are experiencing occasional or frequent problems because of the Internet. You should consider their full impact on your life. | |
Re: [QUOTE=James19142;1002843]What is the difference between a float & double value[/QUOTE] If this is a homework question, have you tried looking in your text? Otherwise, how about [URL="http://lmgtfy.com/?q=float+%26+double+value"]here[/URL]? |
The End.