537 Posted Topics
Re: As soon as you said this: [quote] Could anyone tell me why this code read an extra line?[/quote] I immediately looked for this: [code] while (! in_stream.[COLOR="Red"]eof()[/COLOR]);[/code] This is a very common problem when testing eof() for an end of file condition. Instead try this: [CODE] //Test the return condition … | |
Re: scroll down.. | | | \ / \ / \ / \/ | |
Re: perhaps you could [URL="http://www.cplusplus.com/reference/clibrary/cmath/floor/"]floor() [/URL]the variable prior to testing for zero. | |
Re: [CODE] pToMax = &arr[0]; //should be pToMax = &arr; [/CODE] | |
Re: [CODE] //attempting to initialize with an uninitialized value out of bounds of the array int numOfStudents[100] = students; //function name spelled wrong acceptScores (numOfStudents); //Here you try to pass an array pointer to a function prototyped to accept an int acceptedScores (numOfStudents); //You should dereference the pointer to an int … | |
Re: I would make 'name' a char array (cstring): [CODE] //line #7 char name[80]; [/CODE] Now you can actually accept a name from the user: [CODE] //Line #32 cout << "Enter ye' name: "; cin >> name; [/CODE] Since you are using cstrings (character arrays) you should become very familiar with … | |
Re: From what I understand, an 'unsigned char' datatype will give you straight-up binary properties.. 8 bits, 1 byte, 0 to 255. [quote]My main task is to find a way of generating a boolean array of each character[/quote] I think a pseudo-code for the task at hand could be this: 1. … | |
Re: I'm not sure what you are asking for, but I think you seem to be interested in preserving your white spaces. Try using getline(): [CODE] string line[50]; int pos = 0; int i=0; while(getline(datoteka, line[i])) { //Go back to the start of the line so you can extract data based … | |
Re: Check this out: [url]http://www.daniweb.com/forums/thread240216.html[/url] [quote]Please help me in this program.My problem is that we are given that total budget of a game is 50000 but when the total expenses increases what should we do .....[/quote] You calculate a percentage of 50,000. Then it either falls into one of five categories: … | |
Re: One way I would approach this, is not to worry about templating the function at all until you get a function that does what you want it to do. Once you got that down, you can easily go back and do all the necessary templating. With that said, just concentrate … | |
Re: After briefly looking at ye' code.. I would guess a displayPayment () would probably take place of everything going on between line #47 and #52. | |
A lot of people have questions about how to load a text file using file I/O. There seems to be 2 popular methods to loading a text file: Use fstream's >> extraction operator. Simple enough, load the file directly into individual containers, word at a time, but you lose your … | |
Re: Try this and see if it works: [CODE] //Line #6 void getAge(int&); //Line #24 void getAge(int& years) [/CODE] | |
Re: You want to return the min and max gpa from your binary search tree. Q. Is your tree sorted by gpa? If so, (if ascending order), your lowest gpa would be on the lowest far-left node. Conversely, your high gpa would be on the lowest far-right node. If BST is … | |
Re: If you like programming like I do.. why not learn both..? | |
Re: Check out this cool DOS tutorial [url]http://www.adrianxw.dk/index.html[/url] I believe you might specifically be interested in [URL="http://www.adrianxw.dk/SoftwareSite/Consoles/Consoles5.html"]part 5[/URL] which talks about keyboard and mouse events. | |
Re: line #85, the name of one of your arguments is incorrect: [CODE] showArray1([COLOR="Red"]array1[/COLOR], SIZE); [/CODE] Also, just out of curiosity, why do you have two seperate functions to display an array.. it seems to me that one showArray() function could work for any array. | |
Re: Anyone please feel free to chime in if you see anything wrong here: [CODE] //line #11 if(Temp -> Ch [COLOR="Red"][B]=[/B][/COLOR] CharToDelete) [/CODE] | |
Re: check this out yo [url]http://www.daniweb.com/forums/thread240530.html[/url] | |
Re: Another good ol' database program. This calls for 'an array of structs' create your data type: [CODE] struct record { string description; int product_number; double unit; int sold; }; [/CODE] Now that you have designed your object, you need to create a bunch of them: [CODE] record database[100]; [/CODE] One … | |
Re: [CODE] //line #24 you might have to do this string = &name; [/CODE] | |
Re: [quote]it will say "scout arrived at 100,200" [/quote] After reviewing your loop, this seems to be the correct output in order to establish the terminating condition of your loop.. where toX == currentX AND toY == currentY... which will occur when toX becomes 100 (which is the initialized value of … | |
Re: I agree with twomers, using cin seems to be a 'safer' method than using [URL="http://www.cplusplus.com/reference/iostream/istream/getline/"]getline(), [/URL]in that cin will (unless something wack happens) will read in the entire input buffer while use of getline() will extract everything except the '\n'.. leaving it behind to thwart your subsequent attempts of reading … | |
Re: One thing I notice is that on line #48 you make this assignment: [CODE] b = a;[/CODE] and then on line #30 you totally undo the previous operation with each loop iteration: [CODE] b = start +i; [/CODE] So I'm not sure what you are trying to do, but something … | |
Re: I believe that this may be related to your problem.. You are passing in objects to your functions 'by value' which necessitates the need to save a return value from your functions. [CODE] //you create this stuff int stoodunce[4]; char stoodunce1[4]; cfloat stoodunce3[4]; //and pass it into these functions 'by … | |
Re: I believe that when it comes to bridging the gap between programming and the internet, people seem to recommend the use of [URL="http://msdn.microsoft.com/en-us/library/ms974283.aspx"]activex[/URL] [quote] ActiveXâ„¢ is a technology built on the Component Object Model (COM) that allows the developer to create objects or controls that can be used to "activate" … | |
Re: What you are tasked to do is not really that difficult.. what part of the assignment is giving you the greatest difficulty? | |
Re: [quote]I'm confused with pointers. [/quote] pointer-type variables hold memory addresses.. just like int's hold integers, char's hold ascii values etc. [quote]I'm not sure how to get the vowels to show up in Case A[/quote] Although I do not agree with your current scheme of prompting for user input after a … | |
Re: In my opinion, I think it's possible to decompile an .exe into a somewhat hackish assembly code.... where if a person has a lot of time on their hands, could do a translation from assembly to a higher level lanaguage. (which of course, would probably not even be close to … | |
Re: 1. Create an ifstream object. 2. Create an ofstream object. 3. Attempt to open Expenses.txt using your ifstream object. 4. Perform error checking to see if Expenses.txt actually exists. 5. If file open successful, load file into a storage container of your choice (string, array of strings, or a vector … | |
Re: You are right on brother. One suggestion: whenever you see a self re-assignment, you should have "compound operator" runnin' through your noggin' [CODE] y = y + 1; //is the same thing as y += 1; //The += operator signifies "accumulation" [/CODE] It's such a common task to re-assign a … | |
Re: I'm not sure if this is related to your problem, but I'm pretty sure you aren't allowed to just declare arrays of a given size on demand: [CODE] cout <<endl<<"Please enter the size of the array you want to sort: "; cin >> mysize; //no bueno int mylist[mysize]; [/CODE] I … | |
Re: You are attempting to perform a switch test on a char[50] array. In c++, the switch structure is designed to perform tests on the current state of a single integral expression (the most commonly used are 'int' and 'char'). Additionally, even if you were testing the correct data type, the … | |
Re: Here is a possible pseudo-code for what ye' wish to accomplish: 1. Prompt the user for 5 numbers: [code] do{ cout << "Enter a number: "; cin >> user_picks[i]; i++; }while(i<5);[/CODE] 2. Ensure that user did not make a duplicate pick: [code] do{ cout << "Enter a number: "; cin … | |
Re: [quote] But then how can i convert the grades to grades (letter) i.e. (a, b, c, c, or f)? I am still confused.[/quote] I'm not sure what you are trying to do, but maybe this will help: [code] //Function Prototype char get_grade(int&); //Display Grades for(int i=0; i<10; i++) { cout … | |
Re: [quote] I know I can use a search to find where the first instance of something happens, but how do I actually take whats before it?[/quote] I see that you seem to be interested in using [URL="http://www.cplusplus.com/reference/string/string/"]<string> class member functions [/URL]for your parsing needs. May I suggest the following which … | |
Re: As with any file I/O, I will need to see how your txt file data is formated.. white spaces and new lines are important factors to consider when trying to troubleshoot file I/O. | |
Re: [quote] 3*-4. Any ideas around this?[/quote] In the evaluation of polynomial expressions, it is safe to treat all " - " minus signs as preceding negative numbers (it is safe to assume there is no subtraction). The only special case one must consider is the case of the double negative, … | |
Re: Try this funciton from [URL="http://www.cppreference.com/wiki/stl/algorithm/start"]<algorithm>[/URL] [CODE] #include<algorithm> int array[10000]; fill(&array[0], &array[10000], 0);[/CODE] | |
Re: Although I am by no means a network administrator, this assignment doesn't really seem that overly complex... H[URL="http://www.tech-faq.com/ip-address-classes.shtml"]ere[/URL] is how one can determine the IP class: [quote] [U]Class A[/U]: Class A addresses are specified to networks with large number of total hosts. Class A allows for 126 networks by using … | |
Re: [quote]The problem is that the array size is unknown.[/quote] [CODE] int size = sizeof(array) / sizeof(array[0]); [/CODE] [quote]Is there any way to sort such an array without any lengthy procedures?[/quote] [CODE] #include<algorithm> sort(array[0], array[size]); [/CODE] | |
Re: Well, it certainly looks like you are on the right track.. well stated question and lots of code which shows effort on your part. You've created all the necessary objects with the required attributes and functions. You've created the dynamic arrays of these objects as per the requirement. Your menu … | |
Re: [quote]and then could NOT figure out how to change the parameters of my doOneSet function to do addition, subtraction and multiplication[/quote] There are many ways to go about this. Since you seem interested in changing the parameter list of your doOneSet() function... maybe we could do something like this (ok, … | |
Re: Just looking briefly, I see one error on line #14 of ergasia.h: [code] #define FILENAME "_filenames.txt"[COLOR="Red"];[/COLOR] [/code] | |
Re: This should give ye' at least an idea. I'll draw half of the hexagon, ye' can do the rest. This is untested, but feel free to tweak it as necessary to draw that perfect hexagon: [CODE] #include<iostream> #include<iomanip> void draw_hex() { //Draw Top cout << setw(10); for(int i=0; i<5; i++) … | |
Re: [CODE] char ans = '\0'; int i=0; do{ cout << "\nEnter a number: "; cin >> arr[i]; cout << "\nWould ye' like to enter another number? (Y/N) "; cin >> ans; i++; }while((ans == 'Y' || ans == 'y') && i < SIZE);[/CODE] | |
Re: What part of programming is specifically giving you difficulty? (please provide code with well-written question) | |
Re: Try using getline(cin, user_input); edit: went to go take a wiz, when I came back ya'll had the answers already. | |
Re: You initialize all your string containers to 'white space' and your while() loop condition tests for 'white space' which will always test true (because at no time are they ever changed) |
The End.