2,045 Posted Topics

Member Avatar for joshjgordon

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 …

Member Avatar for jonsca
0
92
Member Avatar for PDB1982

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 …

Member Avatar for jonsca
0
170
Member Avatar for josey_matt

[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 …

Member Avatar for josey_matt
0
127
Member Avatar for dapage

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 …

Member Avatar for jonsca
0
153
Member Avatar for stefanief

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 …

Member Avatar for jonsca
1
116
Member Avatar for NitaB

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]

Member Avatar for NitaB
0
174
Member Avatar for juniper2009

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

Member Avatar for amrith92
0
145
Member Avatar for Richard V

Try the viruses etc forum (also on DW) [url]http://www.daniweb.com/forums/forum64.html[/url]

Member Avatar for jholland1964
0
147
Member Avatar for grib

[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

Member Avatar for Nick Evan
1
133
Member Avatar for foxmulder

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]

Member Avatar for Seten
0
140
Member Avatar for HelloMe

[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] …

Member Avatar for HelloMe
0
79
Member Avatar for HelloMe
Member Avatar for Seten
0
125
Member Avatar for samsons17

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...

Member Avatar for jonsca
0
152
Member Avatar for devo_99

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 …

Member Avatar for devo_99
0
209
Member Avatar for PDB1982

(((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)

Member Avatar for jonsca
0
136
Member Avatar for sexyzebra19

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.

Member Avatar for jonsca
0
94
Member Avatar for T-Dogg3030

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?

Member Avatar for Narue
0
199
Member Avatar for ivanhny

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 …

Member Avatar for jonsca
0
155
Member Avatar for ganmo

[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.

Member Avatar for mrnutty
0
127
Member Avatar for Dannyo329

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 …

Member Avatar for jonsca
0
98
Member Avatar for cnote1287

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 …

Member Avatar for cnote1287
0
118
Member Avatar for plobby

Put a cin.ignore() before your getline() there's probably junk left in the istream.

Member Avatar for jonsca
0
102
Member Avatar for sexyzebra19

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 …

Member Avatar for Clinton Portis
1
204
Member Avatar for Jalwes

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.

Member Avatar for jonsca
0
97
Member Avatar for jdm

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]

Member Avatar for jonsca
0
119
Member Avatar for jonathanYoung

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>).

Member Avatar for Doughnuts
0
118
Member Avatar for tomtetlaw

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 …

Member Avatar for jonsca
0
98
Member Avatar for sexyzebra19

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).

Member Avatar for jonsca
0
126
Member Avatar for sexyzebra19

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 …

Member Avatar for sexyzebra19
0
155
Member Avatar for tkud

Check out the MSDN page for VC++ [url]http://msdn.microsoft.com/en-us/visualc/ee340952.aspx[/url]

Member Avatar for jonsca
0
99
Member Avatar for Instinctlol

declare [icode] double sum; [/icode] within your for loop, sum +=List[K].GetTemperature(); outside of for, output or assign to another variable sum/size;

Member Avatar for jonsca
0
102
Member Avatar for Gem74

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.

Member Avatar for Gem74
0
341
Member Avatar for beatleborg

Please STOP posting on old threads. The two other people still using that version of the compiler either retired or passed away.

Member Avatar for Nick Evan
0
340
Member Avatar for swolll

[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 …

Member Avatar for jonsca
0
225
Member Avatar for nhamyl

[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 :)

Member Avatar for jonsca
0
141
Member Avatar for maverick405

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 …

Member Avatar for VernonDozier
0
146
Member Avatar for fuggles

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.

Member Avatar for jonsca
0
123
Member Avatar for Stefano Mtangoo

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 …

Member Avatar for Stefano Mtangoo
0
193
Member Avatar for new programer

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 …

Member Avatar for jonsca
0
145
Member Avatar for gogodr

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)

Member Avatar for Ravenheart
0
102
Member Avatar for nunchuckie

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 …

Member Avatar for mrnutty
0
153
Member Avatar for anbuninja

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 …

Member Avatar for jonsca
0
110
Member Avatar for turtlez

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]

Member Avatar for turtlez
0
116
Member Avatar for Gerard I MUFC

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 …

Member Avatar for Gerard I MUFC
1
354
Member Avatar for ab00120

[url]http://www.cplusplus.com/reference/iostream/ofstream/open/[/url] Specifically, take a look at the mode option for append.

Member Avatar for jonsca
0
96
Member Avatar for Mattpd

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.

Member Avatar for kvprajapati
0
115
Member Avatar for bestnone

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>> …

Member Avatar for jonsca
0
139
Member Avatar for bamcclur

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.

Member Avatar for bamcclur
0
451
Member Avatar for rafta

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 …

Member Avatar for jonsca
0
85
Member Avatar for new programer

Actually, take the final average calculation (average = sum/5) _outside_ of the for loop otherwise you'll be calculating it each time.

Member Avatar for ScottieF
0
168

The End.