2,045 Posted Topics
Re: If you are referencing those pline[i] values they must exist at that time. Is there a way you could set up SetLine() with default values and then fill them in once you have the pline ones? I understand what you're asking but don't understand how it relates to the dimension … | |
Re: Why not change calculateAverage to return a double (so your average isn't truncated) and call the function in place from your "out" processing. [code] double CalculateAvg (ifstream& students, string studentid[60], string fname[60], string lname[60], int Q1[60], int Q2[60], int Q3[60], int MidTerm[60], int Q4[60], int Q5[60], int Q6[60], int Final[60],int … | |
Re: [icode]void updateFrequency(int size, char grade[],int A,int B,int C,int D,int F) [/icode] should have ABCDF passed in by reference as in [icode]void updateFrequency(int size, char grade[],int & A,int & B,int & C,int & D,int & F)[/icode] so that when you are modifying the counts in the function they are changed in … | |
Re: Your main should never return void, [I]always[/I] an int. You should have return 0; at the end. Using another return statement in the midst of your [code] if (w==1) cout<<"You win!"; else if (w==2) cout<<"You lose!"; else if (t==9&&w==0) cout<<"Tie Game"; [/code] might be a good idea. I haven't familiarized … | |
Re: A few things, it's shaping up :) 1. Switch blocks cannot take multiple characters, they only accept 1, so have the user enter in 1 letter or determine another method (e.g., if-elseif). While you are fixing that, move the code that you use to prompt the user after the case … | |
Re: Is a 2D array the best choice here? You have more than one value corresponding to each "row" number? [code] infile>>row>>col; while(infile) { bacteria[row][col]; infile>>row>>col; } infile.close(); [/code] should probably be something like [code] int i=0; while(infile>>row>>column) { bacteriaX[i] = row; bacteriaY[i] = column; i++; } [/code] | |
Re: Move that entire line 6 out of main and put it before and outside of main. Also, main() should always be int main(), returning 0 at the very end | |
Re: Try the viruses etc forum (also on DW) [url]http://www.daniweb.com/forums/forum64.html[/url] | |
Re: [code] mi = KM_MI * km; gal = L_G * l; [/code] should probably be [code] mi = (1/KM_MI) *km; gal = (1/L_G) *l; [/code] because the units should cancel out in your multiplication mi = (mi/km)*km = mi gal = (gal/L)*L = gal | |
Re: You have no data type on kilometer in your function definition, you must put (int litre, int kilometer). Also, you probably need to cast litre to double [icode] double gas = (double)litre/(kilometer*100); [/icode] | |
Re: [icode] else if (grade[ctr] =2.5) [/icode] should be == instead of = main should be int main You don't need to put void when you are calling the functions in main Your functions don' t actually do anything and are serving more as prompts. For instance you could have [code] … | |
Re: grade[] is an array of strings, it should be ints or doubles | |
Re: Have you covered while loops? Can you make a program that takes in 5 integers? It will be very similar. There's only one cast (AFAIK) that you need to make. Just take it a step at a time and code something... | |
Re: What is your linker error? I was able to get it to compile for me by changing the s in start (the definition) to S. Are you trying to compile this in VC++ 2008? If you chose a blank project it might be giving you guff about it. Also, and … | |
Re: (((double) votes[i])/sum)*100 for each. You need the cast because otherwise you'll get rounded to zero (I went a little crazy on parentheses, but you get the idea) | |
Re: Compare each value to zero, if f(0) < 0 && f(1) > 0 then search in between them (so theoretically you could space your function values at say 5 apart or something and then zero in on it. 5->2.5->1.25 within one interval. | |
Re: Worked for me even without the const on g++ 3.4.2. Was it crashing on you when you tried to run it at that point? | |
Re: Taking the first 25 it seems to be hanging up and rereading the same one for some reason [code] 1 1 o ipod 2 203 2 1 p payment 0 20 3 1 o stereo 0 203 3 1 o stereo 0 203 3 1 o stereo 0 203 3 … | |
Re: [icode] list = list_new; [/icode] doesn't work. It results in the "shallow copy" where just the pointer is transferred. You need to copy it elementwise. | |
Re: Not sure what the issue is, once you right click like you said you get a programs folder. Click on the startup folder then right click and drag your *.exe program (release version if you are using visual studio) into that folder and select create shortcut here. I'll ignore your … | |
Re: How is the file written out? e.g. struct1.member1 struct1.member2 struct2.member1 struct2.member2 I don't think you can read it in with read() that's for char* (I see what you were trying to do with your casting). You may have to read it in member by member (if you know the order … | |
Re: Put a cin.ignore() before your getline() there's probably junk left in the istream. | |
Re: This time you don't need all that precision. Take the fixed and setprecision statements off of the cout(I only told you 7 digits last time so you could see error at 10^-6). P is missing zero by a minuscule amount and continuing. There may be other errors because the approx … | |
Re: Pop a cin.ignore() between lines 32 and 33 (your input was getting corrupted, that throws out anything left over). Also, don't redeclare answer on line 28. | |
Re: The atoi() function should strip out the text as long as the numbers are first. Either that or you could change his getline to one with a delimiter of ' ' (space) [url]http://www.cplusplus.com/reference/iostream/istream/getline/[/url] | |
Re: I think you described it very clearly. What I don't understand is whether or not you have access to the functions in the C++ <string> header (or even <cstring> also named in older versions <string.h>). | |
Re: What you are looking for is called a profiler. One of the advanced Visual Studio packages has one built in but I think it's the Team Suite. I've used a couple in C# but not in C++. [URL="http://stackoverflow.com/questions/67554/whats-the-best-free-c-profiler-for-windows-if-there-are"]Here'[/URL]s a thread with some options. I think people like ANTS but it … | |
Re: How many iterations are you putting in? It may be greater than the maximum value for an integer on your machine ( I only say that because you were starting at the millions before). | |
Re: Hopefully you found it in your code, but the midpoint on an interval from a to b is (a+b)/2 not b. And the opposite signs should be at the ends of the interval, so line 61 should be `if(f1 * f2 > 0.0)` since the sign criteria is showing that … | |
Re: Check out the MSDN page for VC++ [url]http://msdn.microsoft.com/en-us/visualc/ee340952.aspx[/url] | |
Re: declare [icode] double sum; [/icode] within your for loop, sum +=List[K].GetTemperature(); outside of for, output or assign to another variable sum/size; | |
Re: So what is the exact error message that you are getting? I can't repro because we don't have those other two header files (I assume they only have class declarations and are not part of a greater library). Your commented code seems logical at first glance. | |
Re: Please STOP posting on old threads. The two other people still using that version of the compiler either retired or passed away. | |
Re: [quote] companyImp.cpp: In member function 'int Company::read_list(int)': companyImp.cpp:55: error: void value not ignored as it ought to be companyImp.cpp:60: error: void value not ignored as it ought to be [/quote] What is the read_student() method supposed to return (I don't see it but I'm sure it's in another file). Or … | |
Re: [code] #define MAX 999 (no equals) [/code] And you create all_names out of nowhere in two of your functions It doesn't really matter _that_ much, but this is more of a C program than a C++ one :) | |
Re: Scott [I]has[/I] written the functions outside of main. Remember main is in and of itself a function (method really). In the code, you close off main() with } and then give the function _definition_ with return type, parameters, etc. Your _declarations_ (yes you do need all the ones Scott put … | |
Re: You can import with P/Invoke [url]http://msdn.microsoft.com/en-us/library/aa288468(VS.71).aspx[/url] or you can write it in "managed" C++ [url]http://msdn.microsoft.com/en-us/library/aa712574(VS.71).aspx[/url] also, this question comes up a lot at [url]http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/threads[/url] (this is one of their niche issues). And no doubt there's lots of folks lurking here that may know a thing or two about it. | |
Re: This is for SDL but the principles are more than likely the same for anything you will run across. [url]http://www.noquarterarcade.com/setting-up-a-codeblocks-project-with-sdl-on-windows[/url] Scroll down about 3/4 of the way to find the heart of it dealing with the search directories for the compiler and linker. Now that the project has all the … | |
Re: You could have one array[10] of strings that holds the name and another array[10] that holds the averages that come back from the function. Then just iterate to 10 with a cout that displays both name and average. Encase the whole of main(minus your array declarations) in a for loop … | |
Re: how is the size of AllianceCharacters[] determined? You probably need a "new" statement to instantiate the entire array (in addition to its members, which you have done in your method) | |
Re: I agree with Clinton about the b=a thing. I personally think I need another example as to which is which value, but on the surface I think you might need && instead of || in your while loop. You want to make sure if either one of the conditions isn't … | |
Re: Passing an array e.g., func(type a[]) is equivalent to passing func(type * a) anyway, so you already had the pointers working for you. I'm taking a look into whether you may have swapped one of your arrays. EDIT: Found it, this is within your definition: [icode] float calculateGrossPay ( char … | |
Re: I wouldn't bet the farm that this will work for you (as in I don't know) but this is a popular library that is directly involved with web type traffic, works under C++ and interacts with PHP. [url]http://curl.haxx.se/libcurl/php/examples/[/url] | |
Re: I was initially thinking to tell you to use a foreach (should look them up anyway they are useful) but since you are accessing the next element in the list it's not a valid option. [icode] properties.Count [/icode] will give you the information for the size of the list so … | |
Re: [url]http://www.cplusplus.com/reference/iostream/ofstream/open/[/url] Specifically, take a look at the mode option for append. | |
Re: You shouldn't be calling main() like that. In your main() turn your menu into a while loop and call your functions from within. In your function (edit) when the user hits q, just use [icode] return; [/icode] to go back to main. | |
Re: Firstly, this is not a code snippet, code snippets are for things like I have a tried and true function that might benefit the community (or many other related matters but not in general homework). I'm not super sure why you couldn't assign directly to a[3][3] from input. [code] cin>> … | |
Re: Pop [icode] int Counter::nCounters;[/icode] at the top of your counter.cpp file. [url]http://www.cs.loyola.edu/~lawrie/CS301/F03/StaticClassMembers.htm[/url] Also, you don't need to include your cpp file in your h file. | |
Re: Count is not defined in your function as a function has its own scope. Redeclare int count in your function body. Also, you pass in an array called list and you are using the one called student (also not in scope). Within the body of your function you should change … | |
Re: Actually, take the final average calculation (average = sum/5) _outside_ of the for loop otherwise you'll be calculating it each time. |
The End.