1,608 Posted Topics

Member Avatar for Dannielf

game[1]&&game[2]&&game[3]==play That's wrong. && can't be chained like some other operators can be. Change it to :[code] if( (game[1] == play && game[2] == play && game[3] == play) ||............[/code]

Member Avatar for Lerner
0
116
Member Avatar for namehere05

Follow your includes. HashTable.h includes sList.h, but I don't see an sList.h. I do see a List.h, though. Same in List.cpp, you include sList.h instead of List.h.

Member Avatar for namehere05
0
243
Member Avatar for gingo

Frist, it's int main(), not void main(), for portability purposes, meaning, even if your compiler lets you use void, don't. Second, you need a closing curly brace between the end of showplalyer() and the first line of sortplayList(). Third, you need to indicate what type playlist[] is in the first …

Member Avatar for gingo
0
182
Member Avatar for chasee

[code]ptr = new char *[width]; for (int i = 0; i < width; i++) { ptr[i] = new char[height]; }[/code] Code for a 2 dimensional array of char that could be sized to any width and height would stop there. The rest of what you have looks like you would …

Member Avatar for chasee
0
280
Member Avatar for matt_570

>>I have to use character arrays instead of strings. I must use the linear search That pretty much precludes use of a map. It also means you can't use STL strings within a struct, and may preclude use of a vector to hold the structs, too. You could use a …

Member Avatar for matt_570
0
4K
Member Avatar for serkan sendur
Member Avatar for afg_91320

You already have access to arrays and they go great with loops when you want to do the same thing over and over and over. You know you want to get and manipulate information on 4 students. So I'd use a loop to get the same information four times by …

Member Avatar for mrboolf
0
300
Member Avatar for brixton

Apparently the file/program, whatever is located on the D drive in your computer, not the C. It may be that you've partitioned your drive or you have a external drive or something else. You should be able to go someplace to look at the drive contents in the computer. I …

Member Avatar for Lerner
0
176
Member Avatar for Undermine

[code]hours[0]=car1; hours[1]=car2; hours[2]=car3; int b; for( b = 0; b <= 3; b++ ) hours[b] = b;[/code] Why are you bothering to assign values to hours in the first three lines if you are just going to overwrite them in the loop? The loop tries to enter 4 values int …

Member Avatar for Lerner
0
96
Member Avatar for axelgeorge

In a word, portability. int main() is the standard and therefore will work on any compiler which is compliant with the standard. void main() may work on some compilers, but isn't gauranteed to work on any, whether they are compliant with the standard or not. Besides, int has one less …

Member Avatar for Freaky_Chris
0
103
Member Avatar for CE Student

nodeCount, leavesCount and singleParent can all be written using a similar footprint. First declare variables in the tree to act as counters for the number of nodes, the number of leaves and the number of singletons and initialize them to zero in the default constructor. Declare the functions with private …

Member Avatar for Lerner
0
1K
Member Avatar for watersnow14

Use pencil and paper to work out your logic before trying to write the code. It might look something like this:[code] assume: a seat equals an element of the array if value of an element in the array is zero, then seat is available logic: if(decision == 1) if no …

Member Avatar for AmyH2008
0
289
Member Avatar for ItecKid

At least this is wrong: list = pivot; pivot is declared as an int and list is declared as an int array. You can't assign a single into to an array like that. The same holds for these: list >= pivot list < = pivot etc.

Member Avatar for Freaky_Chris
0
109
Member Avatar for acperson

In Invoice.h you declare this function: void print(Invoice) const; However, I don't think you can use Invoice as a parameter to a class member funtion in the Invoice class delaration because the class hasn't been fully declared yet. You can have a pointer to class type in the class declaration, …

Member Avatar for acperson
0
463
Member Avatar for anbuninja

You could probably use any flavor of loop you wish. Generally while loops are used if you aren't certain of the number of times you want to loop whereas for loops are used if you do know the number of times to loop. Do/while forces something to be done at …

Member Avatar for Lerner
0
115
Member Avatar for Nyaato

First, it's int main() not void main(). Your compiler may let you use void, but it's not a wise idea to do so, and it's even one keystroke less to type int rather than void. Second main() usually has two arguments. You can type them in, or leave the parenthesis …

Member Avatar for Lerner
0
186
Member Avatar for Awais Ahmad

That's a better description of the project, but you could have posted it in your original thread. As I see it the trick is to keep track of the original element indexes after you have sorted the array. I can think of two ways to do that. First, copy the …

Member Avatar for Laiq Ahmed
0
136
Member Avatar for Foe89

In getlargest() count will act as the index of the element with the largest rainfall for that year. Since count is passed to getlargest() by reference you don't need to return anything if there are no other requirements of the function. Use some counter variable other than count to control …

Member Avatar for Foe89
0
284
Member Avatar for solimanmuttawa

first, you need to enclose the body of a case statement in curly braces if you want to delare a variable within the body of the case statement. The best answer why I can give you is "because". The algorithm for deleting an arbitrary node from a singly linked list …

Member Avatar for Lerner
0
89
Member Avatar for preet4fun

I'd concatenate the name portions into a single string before output, then print that concatenated string with field width 30 (or whatever) left justified and fill with space char. Then output score with field width 3 right justifed and fill with space char and grade field width 2 right justified …

Member Avatar for Lerner
0
86
Member Avatar for rtmarch

Neither you nor your compiler are being very helpful. Please give some idea about where line 119 is in your code. That's the first place to look. It may not end up being the place with the error, but chances are it's in that neck of the woods. I could …

Member Avatar for TheBeast32
0
125
Member Avatar for nedsnurb

use a loop starting at index zero going to length of string. In body of loop output current char and index using whatever format you want.

Member Avatar for Lerner
0
84
Member Avatar for tori10

during the input loop t is the index of the elements going into the arrays x and y. However, after the input loop t is the number of inputs read from the file. Therefore after the input loop t is not a useful index for accessing loop elements as there …

Member Avatar for tori10
0
164
Member Avatar for Jason123

Don't use the return value of eof() to control the input loop. Use this instead: while (getline (myfile, line)) >>How can i get the digits out from file You have to parse the input, either during the read or after. Looks like the file is a line with a score, …

Member Avatar for Jason123
0
204
Member Avatar for Ameerah

There is more than one error in the program. The one you have been informed of first involves the constructor you have written. In the .h file file you declare the constructor taking a string: Course(string corsename) and you define it inline by placing the {} after the above line …

Member Avatar for Lerner
0
141
Member Avatar for noexit

use a loop asking for input, stopping only when input is valid. Within the loop use the >> to attempt input into a numeric variable. check validity of the istream after the attempt. If it is in the fail state then assume the input was invalid and call the istream …

Member Avatar for Lerner
0
118
Member Avatar for joeblob17

try calling file.clear() after the file is read and before you close it. It's easy to do. It might work. It might not. don't use the return result of eof() to determine whether the body of the loop will be entered.

Member Avatar for joeblob17
0
87
Member Avatar for mastr924

>>It repeats the "Enter the next row:" statement more than once for each time its executed. Looks like it should be printed 9 times according to your code. Specifically when: m = 0, n = 0 m = 0, n = 1 m = 0, n = 2 m = …

Member Avatar for Lerner
0
111
Member Avatar for MJFiggs

Once you enter an value in an array it's there for the duration unless you change the value. One option you have is to keep track of the number of valid values in the array using another variable. All the valid values in the array will be at the indexes …

Member Avatar for MJFiggs
0
121
Member Avatar for MacBarnes

cout is a global object. It isn't passed to the display function. It isn't declared within the display function. Therefore there is only one copy of it. On the other hand, your display() function does declare the ofstream object locally. Since display() is recursive, that means you are trying to …

Member Avatar for cikara21
0
119
Member Avatar for drjay1627

You don't need an h file if you do something like this: void someFunction(); //prototype int main() { someFunction();//call } void someFunction() //definition {} You need all three: prototype, call, and definition. If you define the function before main, then you don't need a prototype. >>'ctid_t' is used as a …

Member Avatar for Lerner
0
256
Member Avatar for dtaylor01

while (depth == 0); { //do something } Take that ending curly brace down to the line with END LOOP. Remove the semicolon after the first line, too. Change this: int calculation; int area (l * w); to this: int calculation = area (l * w); and similar in the …

Member Avatar for Lerner
0
191
Member Avatar for M^2

The only header file you will need is iostream. To accomplish your task you will need to isolate the individual digits as either single digit ints or as char and then display them one at a time with as much space between them as you wish.

Member Avatar for vmanes
0
70
Member Avatar for rastaberry

You should start at the beginning. Learn about the different native data types available in C++. Learn about arrays, strings and lists as common containers for holding information. If the values you will use will only be digits one and zero and you want to manipulate them, then you might …

Member Avatar for rastaberry
0
143
Member Avatar for akira_shinizaki

It takes some work. C++ ostream manipulators take practice getting used to. GUI custom controls are probably the easiest way to get things neat and tidy, but it takes a fair amount of knowledge in C/C++ to get comfortable using that type of code too. A good reference book with …

Member Avatar for Agni
0
94
Member Avatar for akira_shinizaki

One of the other approaches is to never accept input as a numerical type. Only accept input as a string. Then parse the string after input for it's validity as a numeric value and convert the string to the numerical type as desired if it's valid.

Member Avatar for ArkM
0
75
Member Avatar for imput1234

I'd try using strings or develop an internal representation using ints, but a display format that is right justified and filled to left to a specified field size using zeros by using ostream manipulators.

Member Avatar for imput1234
0
68
Member Avatar for akira_shinizaki

You can probably accept input as a string and indicate error if length is longer than four. Bottom line, you can't prevent user from not goofing up. All you can do is try to handle it if it is a goof.

Member Avatar for Lerner
0
265
Member Avatar for vahny

And here's another one, in the following snippet k stops when it is more than what? Or, if you prefer, complete the following if k is less than or equal to what: for(k=0; k<= ; k++; )

Member Avatar for cikara21
0
178
Member Avatar for NinjaLink

your coded logic reads something like this:[code] get information from user, but ignore it for as many songs as there are in the list if list is longer than two delete the second song in the list else assign a value to a flag but never evaluate the flags value[/code] …

Member Avatar for NinjaLink
0
147
Member Avatar for alexdm50

Just as an aside, in this economy a short might be a more accurate variable type than an unsigned long for the balance. Hopefully we don't see the day where char types have enough memory to successfully handle the balances!

Member Avatar for Lerner
0
148
Member Avatar for NinjaLink

1) In your current version of GetNth() what role do the variables number and searchCount play? If you're not going to use them, then delete them. 2) You declare GetNth() to have return type int but on line 28 when you call the function you ignore the return value. If …

Member Avatar for NinjaLink
0
207
Member Avatar for Tausif214

As mrboolf said you probable want to send events and numDays to eventDays, not declare them in eventDays. It may well end up looking something like this:[code] void eventDays(string events[], int numDays[], int size) { //display elements of events in a menu //have user input event number from menu //display …

Member Avatar for Tausif214
0
101
Member Avatar for arreyes

Probably, you can check it out pretty easy. Be careful of the word size. size is frequently used to indicate the actual number of elements currently in the vector as opposed to the number of elements for which space is allocated for vector use, which might be called capacity or …

Member Avatar for ArkM
0
122
Member Avatar for 666kennedy
Member Avatar for mrboolf
0
115
Member Avatar for CantDoThis

1) Welcome to Daniweb! Please take a moment to read the anouncement at the top of the board about using code tags when posting code. The code tags will help preserve the indentation you should be using when writing your code when you post to the board. 2) You program …

Member Avatar for mujash.techee
0
156
Member Avatar for dblbac

:= looks like shorthand for assign. The rest seems pretty much straightforward. Input n values, n = 5 in this case assign the first value to temp for the rest of the values //you can do the rest.

Member Avatar for minas1
0
145
Member Avatar for andrewama

Yes you could rewrite the program to handle dates instead of time. You would need to determine the format(s) you want first. Then start with the basics and write just one function/method at a time, testing as you go. You can post post pertinent code, error messages and questions about …

Member Avatar for Lerner
0
95
Member Avatar for Behi Jon

Read up on loops as they are likely to figure prominently in your program. Provide a better description of your program, it will help you help yourself as well as helping others help you. Show some effort besides just posting your version of the problem description. In particular provide code …

Member Avatar for Lerner
0
89
Member Avatar for davids2004

an int plus an int will always be an int. Have the program do the calculation and store it in an int called temp. Then get user input in an int called answer. Then compare the two numbers using the equals operator within an if conditional with the body of …

Member Avatar for davids2004
0
403

The End.