1,608 Posted Topics

Member Avatar for liphoso

Line 9 and 16 of the code in post #3 are the first lines of function definitions and should not be terminated with a semicolon. Function declarations are terminated by a semicolon, but they aren't followed by a function body (the stuff between the {}s after the first line of …

Member Avatar for WaltP
0
130
Member Avatar for zandiago

If you want to output each word as it is read in you need an output statement doing that as each word is read in. You are using total to be both the total value of each word and the total value of all words, and you can't have it …

Member Avatar for Ancient Dragon
0
501
Member Avatar for helixkod

An alternate method that doesn't rely on using an array to hold each value read in and doesn't use some large number for the initial value of min would be to assign the first value entered to the variable holding smallest value entered. Then with each subsequent value entered compare …

Member Avatar for Lerner
0
280
Member Avatar for Koldsoul

1) Try adding a return statement in double calculate(.....). 2) If you don't have an list of header files in your program, you should have. 3) When you call the function called calculate from the function called main, you should a list of arguments enclosed in parenthesis after the name …

Member Avatar for Koldsoul
0
214
Member Avatar for zandiago

>>2. Which of the numbers is larger may change during the calculation. Make sure to check which is larger every time through the loop (every time functionB() is called). This isn't necessary. The determination of largest and smallest only needs to be made once for each set of inputs as …

Member Avatar for zandiago
0
259
Member Avatar for zandiago

You never increment i or num each time you go through the loop. Remember, trying to divide by 0 will cause problems! Given the requirements of the project I'd read the entire file into a container, then I'd loop through the container to add all the grades and divide by …

Member Avatar for zandiago
0
564
Member Avatar for Fool

The string/loop approach is probably the best at this point, however, you need some mechanism to add two values together, which I think is what Zandiago was trying to point out. I'd recommend taking a step few steps back and try answering each of the following questions one at a …

Member Avatar for Fool
0
317
Member Avatar for Ashu@sym

To me, when doing C/C++: 0 would digit zero, that is, a numerical value. '0' could be the character capital oh or the character zero. For example: char word[10] = "Oxford"; char number[10] = "01234"; Depending on typeface used 'O' may look exactly like '0' making it difficult to tell …

Member Avatar for Ashu@sym
-1
7K
Member Avatar for kamlesh_ag07

namespace is a keyword in standard C++ that indicates a container of information. For example, namespace std contains all the standard header files such as iostream, cctype, string, cmath, etc and their contents such as cin, cout, and the int, float, char types, etc. You can declare your own namespaces …

Member Avatar for ChaseVoid
0
97
Member Avatar for louise07

Welcome to Daniweb! Unfortunately your post is quite vague. Do you want to print the contents of a linked list somewhere (screen, output file, printer, other) or do you want to store the contents of a file in a linked list and then print that somewhere?

Member Avatar for louise07
0
90
Member Avatar for zandiago

>> it's now saying that my case statement's are illegal It looks like you're missing a }. >>how to modify the program so that after the user calcualtes the volume of one object the program automatically goes back to the menu Put the menu lines inside the while loop, before …

Member Avatar for zandiago
0
195
Member Avatar for ThePhenom

Welcome to DaniWeb! Congrats on use of code tags when posting code to this board! The use of void as the return type for main() on code posted here will earn you demerits if done over time. The return type for main() should be int because: it's the standard, even …

Member Avatar for ThePhenom
0
136
Member Avatar for sarah24

1) Welcome to DaniWeb! 2) When posting code to this board use code tags. How to use them is explained in the watermark in the message input box and in one of the "sticky" messages at the top of the board. Some of the people here won't respond to your …

Member Avatar for Lerner
0
233
Member Avatar for teppuus

Debugging is an art in itself. To debug this type of problem I'd consider any and/or all of the following until I figured it out: 1) start commenting out one section of the if/else statements at a time to see where the second request statement is coming from, or 2) …

Member Avatar for Salem
0
132
Member Avatar for chris53825

Each student has a grade list, but each grade doesn't have a student list so the lists/nodes aren't mutually dependent. Therefore declare the gradeNode before the studentNode and have each studentNode contain a pointer to a gradeNode as a data member.

Member Avatar for Narue
0
124
Member Avatar for zandiago

I'll toss a few more concerns in to the mix in adddition to those already pointed out by iamthwee. room and grad are declared as string variables but you are trying to compare them to a literal characters when doing things like room == 'R'. Change the declaration of room …

Member Avatar for iamthwee
0
2K
Member Avatar for kahaj

Add a call to cin.get(); just before the call to return 0; in main() to try to hold the program open for viewing. Better yet, use two calls to cin.get(), or do as I do, which doesn't seem to be the mainstream, and call >> on a dummy variable just …

Member Avatar for Ancient Dragon
0
600
Member Avatar for angelfox

Welcome to Daniweb. I see that Wolfpack helped formating your code since it was your first post. In the future please use code tags when posting information, like code, where you want to preserve indentation. As another alternative you could use the array and a loop to read through array …

Member Avatar for angelfox
0
170
Member Avatar for shannonpaul

shannonpaul: Control loops come in three varieties: for, while, and do/while. Each loop has one or more keywords (telling what type of loop it is), a body (usuallly telling what to do each time through the loop), and a conditional (indicating when or how often or how many times the …

Member Avatar for ndeniche
0
128
Member Avatar for sandile77

1) Welcome to DaniWeb! Please use code tags for future posts with code or indentation you wish to preserve. 2) Please describe what problem you are experiencing. Does the code you post not compile? Does it compile but not run? Does it run but give erroneous output? Do you get …

Member Avatar for Lerner
0
101
Member Avatar for revenge2

revenge2: In addition to Salem's corrections please note that the << operator is for ostreams like cout and >> is for istreams like cin. Unfortunately you are calling << on both cout and cin. mypopope: The compiler/linker need to see either a function declaration (prototype) or a function definition before …

Member Avatar for darkagn
0
145
Member Avatar for sjewenp

To be able to help you best we need to know what tools you have available. For example if you don't know the first thing about the Standard Template Library then Ancient Dragon's solution isn't going to help much. If you don't know STL then you'll need to use dynamic …

Member Avatar for Lerner
0
278
Member Avatar for vikter

To get to your direct question, there is no good way to delete a element from an array. You could: 1)add a flag to the struct indicating that the current struct can be used or not. 2)or you could overwrite the struct you wish to delete and shift all structs …

Member Avatar for vikter
0
112
Member Avatar for khalidxa

int swap=matrix[m][k]; cout<<""<<swap[m][k]; In line one swap is declared as an int and is initialized with an int value. In line two swap is used as a 2 dimensional array. swap can't be both an int and a 2 dimensional array. swap was declared as an int and never as …

Member Avatar for pradeepk
0
107
Member Avatar for toko

[code] int CelciustoFahrenheitInput() { //drop the int in the next line. //you want to call the function here //what this line is doing as written is declaring a function prototype int CelciustoFahrenheit(); } [/code] In addition, it would work best to pass the value of c obtained in that function …

Member Avatar for ndeniche
0
126
Member Avatar for mauro21pl

[code] void Money::input (istream& ins) { cout<<"\n\nYou are going to set up the amount for your_account"<<endl; cout<<"Enter the amount to your_account: "; bool negative; char first_character; char decimal_point; if (first_character=='-') { negative=true; ins>>first_character; } else negative=false; if(negative) { ins>>dollar_amount>>decimal_point>>cent_amount; [/code] cin is a global istream object that is predeclared for …

Member Avatar for Lerner
0
102
Member Avatar for rainbow78

>>I'm really getting lost, when making the loop to have the user put in the 10 names, you would do something like for (int i=0; i<11; i++) Not quite. Use your fingers to count starting at, and including, zero and going through, and including 10. How many numbers did you …

Member Avatar for spider_pig
0
99
Member Avatar for zandiago

[code] /*If you don't use {} after a control statement (for, while, do/while, if, etc) then the body of the statement will be just the first line after the statement. To have more than one line in the body after the statement enclose all the lines you want in the …

Member Avatar for zandiago
0
2K
Member Avatar for zandiago

As I understand it, the file random.dat already has 1000 values between 10 and 100 before you run this protocol. Now you want to read random.dat and determine what unique values between 10 and 100 are present in random.dat. To know whether the current value is unique you will need …

Member Avatar for Lerner
0
417
Member Avatar for Earth Wyrm

One or the other or a combination of these suggestion may be helpful [code] fstream OutputFile; //try removing the ios::app mode until you can write to file in the first place OutputFile.open("Notes.txt", ios::out|ios::app); if (!OutputFile.good()) { MessageBox(hwndContainer, "There has been a problem opening the file", "File error", MB_OK); } //try …

Member Avatar for Earth Wyrm
0
167
Member Avatar for jenco

Presumably Edit1->Text is a string of some type. Assuming this is a Windows based program, then it's probably a C style string. If that assumption is correct then each letter in the string can be accessed by using the [] operator, like this: Edit1->Text[x]; where x ranges from 0 to …

Member Avatar for Lerner
0
228
Member Avatar for khalidxa

[code] class testCase { public: int caseId; int matrix[cellId][freq]; testCase::testCase(int i, int *matrix2[][2], float mFit) { this->caseId=i; this->matrix[cellId][freq]=*matrix2[][2]; this->fitn=mFit; [/code] I see no reason to be using the scope operator in the above snippet since the definition you are coding is occuring within the declaration. Using the this pointer is …

Member Avatar for Lerner
0
116
Member Avatar for ShawnCplus

Are you sure you can assign a variable of type char to a variable of type string?

Member Avatar for ShawnCplus
0
1K
Member Avatar for hinduengg

Since this is probably a learning experience in how to manipulate data rather than scrounging the archives of the Standard Template Library, I would suggest you consider this: Using the JAY example if you did this: JAY JYA AJY AYJ YJA YAJ and note that you can get all permutations …

Member Avatar for hinduengg
0
1K
Member Avatar for Narue

Goal: Reverse words in a sentence without destroying sentence and without using STL. Assumptions: 1) Input sentence not longer than 6400 char 2) Less than 81 words per sentence 3) Each word less than 81 char long 4) Output is a sentence with words reversed [code] #include <iostream> #include <cstring> …

Member Avatar for Bench
0
498
Member Avatar for radskate360

1) use code tags when posting code to this board 2) You don't need these: time_t t; time(&t); yl; cls; so I'd get them out of there to avoid polluting the landscape. 3) Don't use the return value of eof() to control loops. Sooner or later it's going to cause …

Member Avatar for iamthwee
0
170
Member Avatar for shalini_roy

One way is to generate a container containing all numbers 1 to x, then generate a container filled with all fibonocci numbers 1 to x, then all numbers that aren't fibonacci numbers in 1 to x go in a third container that will contain all nonfibonacci numbers 1 to x.

Member Avatar for WaltP
0
196
Member Avatar for radskate360

>> understanding behind arrays Without knowing what you know already this may be difficult, but here's a general presentation. Arrays are variables that can hold the information about a group of objects in contiguous memory. You can use an array almost like any other object. For example you can refer …

Member Avatar for Lerner
0
629
Member Avatar for Teresa_Hall
Member Avatar for Narue
0
238
Member Avatar for radskate360

You will need to store each value of number2 in a container as it's generated. When all the values of number2 have been generated then sort the container from high to low. Then use a loop using a counter (you could use second to do that) that ranges from 1 …

Member Avatar for Lerner
0
107
Member Avatar for tunday
Member Avatar for Ahmed Padela

Look up how to write a 2 dimensional array using dynamic memory and then how to access a given element of said array. Then write a routine as to how to access each element of a given row. Then write a routine as to how to access each element of …

Member Avatar for Ahmed Padela
0
215
Member Avatar for blazted

Declare a char variable to hold the math operator you want to use, then pass the operator to a switch statement where each case of the switch statement implements the desired math procedure desired based on the char passed.

Member Avatar for Lerner
0
97
Member Avatar for nkhosinathie

One way to do this is to store the data as it's entered so you can then analyze the data once it's all entered. Containers (for example, arrays) could be used to hold the data. If you don't want to use classes then I'd consider having several 2 dimensional arrays …

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

I suspect your code compiles but provides unexpeceted output. I think it helps if you write out what you want to do first, then try to write code. I've attached a number of comments to your code indicating what I think your code is doing. If you write out what …

Member Avatar for meiyantao
0
181
Member Avatar for jpknoob

do you mean something like: if((usersGuess - random == 1) || (usersGuess - random == -1)) or if(abs(usersGuess - random) == 1)

Member Avatar for Lerner
0
96
Member Avatar for JaksLax

I suspect you're either reading/writing out of bounds on one of your arrrays or you have overfilled the stack. Since the latter is quiet easy to check, I'd check that first. To do it, declare randomArray on the heap using dynamic memory allocation rather than on the stack using static …

Member Avatar for Salem
0
145
Member Avatar for ghadahelal
Re: hex

I would think sprintf() is as much C++ as null terminated char arrays are. However, if you don't like using C style I/O and all you want to do is to see the hex equivalent of a value, not manipulate the hex equivalent of a value, then there is a …

Member Avatar for WaltP
0
219
Member Avatar for MarzenaM

You could always try this syntax: vector<int> sample_array(10); if you want a vector of ints with space for exactly 10 ints and don't want to call resize(). If you find that the stuff you do in fill() and sort() aren't maintained in the vector in the calling function, then you …

Member Avatar for Lerner
0
112
Member Avatar for xaphan

Welcome. I'm not sure how you managed to enclose your code in a pretty grey box but I hope it was that process and not your coding style that left justified every line. It is much easier to read code that is indented consistently. I would also suggest you start …

Member Avatar for Lerner
0
83

The End.