1,608 Posted Topics

Member Avatar for ricnyx

if you wish to use >> to read the file, which is okay, then use this scheme: [code] string dayName double income //read one full line of file each time through the loop while(fin >> dayName) fin >> income [/code]

Member Avatar for Lerner
-1
108
Member Avatar for brlukosk

You are displaying the screen with cout rather than writing to file with a user declared stream object. You are only outputting a single Product, not a group of Prtoducts. There are other syntax errors in the code as well, but these are the big ones I see in the …

Member Avatar for Lerner
0
1K
Member Avatar for johny112

Look up the concept of nested loops in your reference material. It means a loop within a loop, and is a commonly used technique so there shouldn't be any problem finding a number of references. Then post code and specific questions about the code, error messages, etc, as necessary.

Member Avatar for johny112
0
103
Member Avatar for misdongard

The first thing to do is to forget about the compiler for a while. Use a pencil and paper and try to work some things out. For example : What information is contained in the file about each client and how might you represent that using data types? What containers …

Member Avatar for Lerner
0
77
Member Avatar for fudawala

Use cout to put the column lables you want between the second and third loop. Then format the output statement in the third loop so the output lines up under the appropriate label.

Member Avatar for Ancient Dragon
0
2K
Member Avatar for phalaris_trip

I think this will work CPoint** points; make points a pointer to an array of pointers of type Cpoint*: points = new CPoint*[200]; each points[i] in points is a pointer to type CPoint so now you can call member functions using the -> points[i]->Move(); if that's what you really want …

Member Avatar for Duoas
0
109
Member Avatar for powellinthesout

Beware that neither iostream.h nor conio.h are standard and therefore may not be available with all compilers. Likewise, recommending void main() on this board is even more likely to earn a reprimand than recommending nonstandard headers. main() should return an int, for a number of reasons. NB: Salem types too …

Member Avatar for Lerner
0
76
Member Avatar for joceyn226

Options: 1)Drop the validation routine until you get the program flow working, then come back and add it later. If it turns out the validation scheme isn't working, and I think that's the problem, then you'll know where to look and be able to ask a better question. 2) Place …

Member Avatar for Ancient Dragon
0
98
Member Avatar for mrgreen108

I guess there are almost as many ways to learn computer programming as there are computer programmers. A couple of the contrasting styles include taking advantage of standard, already developed material vs reinventing each standard, well developed material in the name of education and understanding. If you're a fan of …

Member Avatar for vmanes
0
121
Member Avatar for DREAMER546

>>That's generating actual objects called User1 and User2. What you want to do is typedef them But why does he want two user defined types with exactly the same innards? Why not two objects/variables of a single type?

Member Avatar for DREAMER546
0
114
Member Avatar for Awais Ahmad

Sometimes when English isn't your native language it is even more difficult to explain what you want to do than it is for us native English speakers. To use multidiminsional arrays you can do something like this: int array[2][2]; which declares a variable on the stack with enough memory for …

Member Avatar for Lerner
0
118
Member Avatar for c++ prog

to convert the char representation of an int into an int you could do this: char x = '4'; int y = x - '0'; where the second line means assign the difference of the ASCII (or other char set) value of zero from the ASCII (or other char set) …

Member Avatar for Lerner
0
128
Member Avatar for malathuis

Please use code tags when posting code to this board. You need to do multiple comparison's like this: if(choice == 'B' || choice == 'b') The three instances of that error is the only thing I see when looking quickly over your code.

Member Avatar for ravenous
0
60
Member Avatar for dsuh06

Here's a good online reference of standard functions used in both C and C++. You can use it for future reference and confirm the following. To use getline() with C style strings you need an istream object like cin or an ifstream object. You also need a C style string …

Member Avatar for dsuh06
0
1K
Member Avatar for k88joshi
Re: C++

[url]http://www.cppreference.com/stdstring/strstr.html[/url] You could look at this site to see if it's an example of what you are trying to do. There is a convenient conversion from string to C style string if there isn't a similar method built into the string class.

Member Avatar for iamthwee
0
132
Member Avatar for jbennet

To be standard drop the .h after iostream. The iostream header file is different from the iostream.h header, though functionally the are the same (the purists, specialists, experts may be aware of some subtle differences, but for us mere mortals they function the same). iostream, however, is the standard at …

Member Avatar for jbennet
0
152
Member Avatar for Trucks

>>is there a way to make it read the values based on whitespace or something? There are all sorts of search/reading/parsing routines that can be used based on each individual search criteria. Let's say that each line has a minimimum of 6 substrings all separated from one another by spaces. …

Member Avatar for Lerner
0
101
Member Avatar for guitarrick

Depending on restrictions there is a function in the algorithm header file of the standard template library that will "automagically" shuffle a given group of items. However, that would take the fun and learning experience out of implementing the routine on your own.

Member Avatar for guitarrick
0
249
Member Avatar for still_learning

Post your current code or try printing out the values of S.pop() and Q.frontQueue() to screen to be sure you are getting the values you expect when you run a test program.

Member Avatar for Lerner
0
94
Member Avatar for chrisliando

What language/environment are you trying to work in (standard C/C++, Windows, Mac, C#, Delphi, other???). If it's anything besides C/++, Windows, Linux, or other C/C++ related specialty environments then there may be a better forum to ask these questions in. If it's Windows/Linux then the number of respondents familiar/comfortable with …

Member Avatar for Lerner
0
170
Member Avatar for maxmaxwell

If mode is the most frequently occuring number then find the frequency of the first number in the array. Since it's the most frequent value you've found so far it must be the most frequent at the moment. Then find the frequency of the second number in the array and …

Member Avatar for maxmaxwell
0
136
Member Avatar for neilyan

You mean something like this: [code] if ( sections == 1) //first class reqeusted { if(firstClass < 4)//implies there's only 4 first class seats available on this flight ++firstClass; //assign a seat in first class } [/code]

Member Avatar for neilyan
0
108
Member Avatar for guitarrick

Maybe this syntax will allow for nice looking columns. char space = ' '; char bar = '|'; //Header line: cout << space << space << 1 << space << 2 << space << 3 << space << 4 << endl; //line 2: cout << 1 << bar << grid[0][0] …

Member Avatar for Duoas
0
98
Member Avatar for holeejo

open the file in textBox1 to read the text in the file // stumpted read text into a string or char variable // stumpted Which is why I would recommend you learn about standard C/C++ before trying to do nonstandard stuff like Windows, unless this is part of a class …

Member Avatar for sillyboy
0
287
Member Avatar for sean25hun

//intialises x //intialises y Nope those are declarations. The value of x and y at this point is random junk. This would be a declaration and initialization: int x = 0; _________________________ //intialises from zero to 10 Nope. That statement validates that x is has value of 0 to 9 …

Member Avatar for Lerner
0
95
Member Avatar for dblbac

>>any help or ideas is greatly appreciated Don't blindly copy and paste and expect the code to work. It sends a pretty loud message, that most people don't want to hear. If you want to use functions, then use them, but don't just slap into your program somewhere. For now, …

Member Avatar for dblbac
0
118
Member Avatar for sean25hun

The x in Narue's code is an arbritrary name for the index used in referencing each element of the array. She could have used sassafrass or i or y or any other variable name she wanted. To display the values within an array you can loop through them one by …

Member Avatar for Lerner
0
81
Member Avatar for guitarrick

Functions, like variables, need to be declared before being used. They can be declared from within other functions, though most frequently, they are declared before main() is called. Then, paralleling the need to give a variable some meaningful variable before trying to use it, you need to provide the function …

Member Avatar for guitarrick
0
197
Member Avatar for dblbac

Unless you've changed it by now your code has this snippet: [code] int noOfGuesses = 0; int ncount; int sum=0; int noOfguesses; int noofgamesplayed; int avgNoOfGuesses; sum+=noOfGuesses; avgNoOfGuesses=sum/noofgamesplayed; [/code] This: int noOfguesses; is a duplicate of this: int noOfGuesses = 0; and needs to go if you haven't already gotten …

Member Avatar for Lerner
0
212
Member Avatar for Lerner

I'm frustrated at the moment and thought I'd vent a bit before asking for help. I've finally decided to download MS Visual C++ Express 2005 and migrate from VC++ 6.0. I know, it's about time! What can I say, except that I hardly ever download stuff from the net because …

Member Avatar for Lerner
0
122
Member Avatar for helixkod

it's at least an off by one error in divisionChange. When y goes from 1 to 3 then y + 1 goes from 2 to 4 but 4 as an index for quarters isn't legal. The legal indexes for quarters are 0 to 3.

Member Avatar for Ancient Dragon
0
327
Member Avatar for dblbac

To look it up it's frequently called a nested loop since one loop sits inside another. Any type loop can be used in either position. Can have more than one nested loop, more than one layer of nested loops, etc. [code] outer loop //control whether to guess a number generate …

Member Avatar for dblbac
0
156
Member Avatar for vaishal

the simplest place to start is just get the base program running. #include <iostream> int main() {} compile and run that. Then add no more than one function, loop, or control statement at a time and compile, run, test after each addition. Since your file input is standardized you could …

Member Avatar for Lerner
0
98
Member Avatar for abarnett

I don't see where you initialize standardExemption before you try to use it in calculation of taxableIncome. Once you have taxableIncome you need to subject it to the pertinent tax rate given in the instructions before returning the tax as taxableIncome isn't taxed at 100% (yet, anyway). You can use …

Member Avatar for WaltP
0
3K
Member Avatar for rogenie

At the end of the second for loop count equals NUM_ARRAY. count isn't changed between then and it's use in the terminating condition in the third for loop. This means that in the third for loop numHolder[count] is the same as numHolder[NUM_ARRAY] which is out of bounds. The same argument …

Member Avatar for rogenie
0
124
Member Avatar for gerronk

In a test program write this: cout << argv[2] << endl; and see what happens. argv[2] IS the equation in the form a C style null terminated string. You can copy this to another C style string using strcpy() or you could initialize another C style string with argv[2] if …

Member Avatar for Lerner
0
159
Member Avatar for chizy2
Member Avatar for chizy2
0
143
Member Avatar for zandiago

void initialize(char letter[26], string food[26], double cost[26]); Just like your answer said in #4: >>so if i din't want to use a struct, each time in my functions where I have fastfood...i'd have to replace it with: char letter[]; string food[]; double cost[];

Member Avatar for zandiago
0
158
Member Avatar for aus_fas1

frame[1].dist[0] This syntax implies that frame is a object for which the [] operator is overloaded-----for example and array, a vector or maybe a map. Assuming it's an array based on your post then frame could be declared one of two ways: Frame frame[MAXSIZE]; Frame * frame = new Frame[MAXSIZE]; …

Member Avatar for Lerner
0
99
Member Avatar for zandiago

Each line in the file could be read in as a string. The first string would be stored as the correct answer string. The remaining lines alternate between student ID strings and the student answer strings. Once you have a student answer string you compare each element of that string …

Member Avatar for zandiago
0
3K
Member Avatar for danielle2

OK, now use a nested loop to enter data into array. Here's a very basic outline of a nested loop using for loops. You have to fill in the necessary details as per your project instructions. [code] for() //this loop will control which row you're using { for() //this loop …

Member Avatar for Lerner
0
317
Member Avatar for hasfoot

The program is reading the file line by line as written. What it looks like you need to do is figure out a way to parse (break it up into definable chunks) each line. I think you can do it with the getline() version for C strings if you want. …

Member Avatar for Lerner
0
166
Member Avatar for tom1989

My crystal ball is pretty cloudy right now. If you want more help please be more specific, like post your code (using code tags) and information about what it is exactly that you are trying to do.

Member Avatar for vmanes
0
92
Member Avatar for barbie 2

Will the file be one word per line or do you have to parse the line into individual words. Once you have a single word I'd send it to vowel(). I don't know why you would want to send three strings to vowel(). You don't really need the string word …

Member Avatar for tostrinj
0
155
Member Avatar for dabu

Data validation isn't an easy process, but it isn't rocket science either. There are two common approaches. The first is to never accept input as any type other than as a string because strings are always valid. Doing this you would then validate that all the characters in the string …

Member Avatar for Lerner
0
155
Member Avatar for cl3m0ns

Unexpected error of what type? Of hand I'd be concerned that when name == "stop" there is no corresponding score so trying to display one may cause a problem. Alternatively, using ATIME as an index as in below: DisplayArrays(studentNames[ATIME], scores[ATIME]); is an error since the last valid index is ATIME …

Member Avatar for tracethepath
0
86
Member Avatar for anga08628

Declare an array of type student in main() just like you'd declare an array of type int or an array of type double. Also change this: void sets ([]); to something like this: void sets(student studentArray[], int size); and make the appropriate changes in the definition as well. In the …

Member Avatar for prushik
0
115
Member Avatar for cl3m0ns

EIther test the name before you enter it into the name array and break out of the loop if it equals "stop" without entering "stop" into the array (which is what I think twomers is suggesting) or, alternatively, leave "stop" as a name in the array, but when you display …

Member Avatar for cl3m0ns
0
126
Member Avatar for still_learning

Building your first hand rolled linked list is hard enough, let alone trying to do it with templates. As to your post #6 in this thread, there is nothing there that needs something out of namespace std. If you have a statement such as: using namespace std; after you list …

Member Avatar for Duoas
0
223
Member Avatar for c++beginnerer

Overload the << operator for the struct/class to output all the information you want in one operation using whatever format you want. //declare the struct struct mine {//whatever}; //declare an array of 10 structs of type mine mine myStructArray[10]; If you don't know the number of items to go into …

Member Avatar for Lerner
0
95

The End.