2,827 Posted Topics
Re: Right off the bat, I see a few problems just in the very beginning: [code=C++] #include<iostream> //Librerias #include<cmath> //Librerias using namespace std; /* Function prototypes */ void Ingrades (double[][10], int); // Function that lets user input student ID, two partial exams one final, two quizzes and one project and studentCount … | |
Re: Here's a decent thread on the subject. Since you mentioned "DOS", I assume you really mean "Windows Console" since very few people use DOS now. [url]http://www.dreamincode.net/forums/showtopic9880.htm[/url] I couldn't get it to work for me, but I didn't play with it for all that long. It looked like it worked for … | |
![]() | Re: phoneNumber = toDigit(int & d) Two small problems. 1. Leave off the "int &". This is a function CALL, so leave off the type. 2. You forgot the semicolon. Try changing line 67 to this. phoneNumber = toDigit(d); |
Re: Does it compile? Does it run to completion? Does it crash? Where? What was the input? What was the expected output? What actually happened? Details, details, details. This one's pretty easy though. Let's take a look at gets. http://www.cplusplus.com/reference/clibrary/cstdio/gets/ char * gets ( char * str ); Further down on … | |
I have an abstract class. I'm creating a large array in the base class, which appears to never be deleted because no destructor is called. My questions (obviously) are... * Why isn't a destructor called? * How do I fix it? #include <iostream> using namespace std; class A { protected: … | |
Re: > Thankfully, disable ads was(is) not a paid feature Is this new with the update? I always thought it WAS a paid feature. Never noticed that little check-box till you mentioned it. How long's that been there? As to the fade effect, it annoyed the heck out of me until … | |
Re: How about making a temporary 3 x 4 array, initialize it as you have done, then in your for loop, do a memcpy of the 3 x 4 array to the address of element array[T][0][0]? const int temp[3][4] = {{4,2,6,4},{5,2,5,3},{6,3,1,5}}; int array[5][4][3]; // Replace line 3 in your original code … | |
![]() | Re: A rectangle is a polygon with four sides where the opposite sides are equal. I imagine it would inherit everything that polygon has, plus add a constructor taking a length and a width and some getters and setters. Who wrote this code? > but i have no idea what i'm … |
![]() | Re: Your postings are all messed up with the line numbers. Where are you copying and pasting from? |
I can't seem to copy and paste code form posts anymore. I get one big run-on line. The newlines no longer work. I also get all the line numbers, which means the code can't compile. Is there a "toggle plain text" option so I can copy and paste into an … | |
Re: Delete lines 5 and 6. There are no floating point values anywhere in this problem. Line 8 - I assume you are trying to declare a 2 x 5 array? Shouldn't this be 2 x 4? That's what you have in your example. Change line 8 to this. char spaceLayout[2][4]; … | |
Re: > copy the string from the first point in the file to the index of comma -1 Copy to where? Another file? A memory buffer in the program? Display on the console? If it's a memory buffer in the program, you'll need to allocate storage with malloc or something else. … | |
Re: When in doubt, break it into several lines. Think about it. If it works, the increment has to happen after the assignment and the while test has to happen AFTER the assignment. Otherwise you'd either get complete garbage or miss the first or last character or miss the entire last … | |
Re: Sounds like another thread of the perils of mixing cin and getline. See this thread. http://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream After line 8, there's an extra '\n' in the input stream. Line 10 gobbles that up and doesn't pause. Whenever you use getline immediately after cin with the >> operator, you need to get … | |
Re: If you have three columns and the delimiter is a tab, I imagine the best way to handle it is to read the whole line, then use the find_first_of function from the string library with a '\t' as the character to look for. That returns the index of the tab, … | |
Re: Aside from all of the above, I'll add this. For checkers, you'd have to write a graphical user interface. You could write one without, I suppose, but I don't think it would look very good. All of the original checkers games were console, but we've gotten spoiled. For blackjack, a … | |
Re: (B - A) / A can't be calculated unless A and B and the rest of the letters have numerical values, so that's a question even before getting to the array aspect of your question. I assume that all the types are doubles? You don't mention that. Best not to … | |
Re: [QUOTE=volscolts16;711208]I apologize I put the code between brackets but its not working is it b/c of the length?[/QUOTE] Code tags syntax: [noparse] [code] // paste code here [/code] or [code=cplusplus] // paste code here [/code] [/noparse] Note that there are no spaces between the opening and closing bracket pairs. The … | |
function validate_font_family($font_family, &$error_message) { $valid_match1 = '"Times New Roman",Georgia,Serif'; $valid_match2 = '"Arial",Georgia,Serif'; if(preg_match($valid_match1, $font_family) || preg_match($valid_match2, $font_family)) { return true; } $error_message = "Invalid font family(" . $font_family . "). Must be either "; $error_message .= $valid_match1 . " or " . $valid_match2; return false; } The code is supposed … | |
Re: I didn't see anywhere that specified the input filename, so I assume it is argv[1]? Here's my submission. I think it works if I understand the problem correctly. [code] #include <iostream> #include <fstream> #include <cassert> using namespace std; unsigned int Log2 (unsigned int number) // assumes number is greater than … | |
Re: You need to narrow down precisely where the problems is. Several possiblities. * Input from the file is not successfully going into the objects. * Objects are not being outputted correctly. * All sorts of subsets of the above. * You have a whole bunch of "PS" variabes in there. … | |
Re: If you're going for efficiency, make line constant and get rid of the calls to "compare". You're comparing one character strictly for equality, so just compare the characters... if(line[ss] == '=') // or any of the other comparisons The overhead of [] is negligible. There's some quick math to get … | |
Re: http://en.cppreference.com/w/cpp/language/operator_precedence You have a complex statement, Break it up into smaller statements using the order of precedence. It's an easy question. You'll get a is 0 even if you screw up the order of precedence. You have three statements, not necessarily in this order. Study the order of precedence and … | |
Re: All sorts of ideas. Where are you stuck? The math? The programming? What part of the math? What part of the programming? | |
Re: The thread in question is a great example of a thread that SHOULD be ignored. The response that the first poster gave was a decent one in many respects, though I agree that it would have been better had the poster confined himself to simply explaining how the question needed … | |
Re: I can't get anything from the link, so it's hard to see the context. From what I can see, though, the function seems wrong. When I plug in 0 for an angle, it seems to me that no values should change (rotating a line by 0 degrees should have it … | |
http://www.daniweb.com/software-development/cpp/threads/421755/simple-2d-rotation-problem Scroll down to any of my posts with code. They don't have that nice numbering and highling everyone else's has. I wrote my code in a text editor, copied it to the post, highlighted it, then clicked "Code". I feel pretty confident I didn't click "Inline Code". Anyway, it … | |
Re: First you need to figure out prececisely where this is crashing. It can be any number of places for any number of reasons. Quickest, easiest way to find that out is to stick some debugging statements in various parts of the program, followed by some "cin.get()" calls to pause the … | |
Re: You need to start over from scratch. Lines 39 to 42 show that you don't understand the difference between a single object and an array. You should also be using structures if you know them already. This function is a segmentation fault waiting to happen since you are using illegal … | |
Re: main is a function, the loop isn't, but you are CALLING functions linke "sqrt" and "system". I'm guessing that's what they mean. | |
Re: >> How to send more than one file to command line arguments. "Send"? Send how? From where? I assume you mean fileNAMES, not files? You want to do something like this?? ./programname filename1 filename2 filename3 foldername then have the C++ code parse the command line argunments and dowomething with them? … | |
Re: 1. Get rid of conio.h altogether. 2. Change iostream.h to iostream. 3. Change void main() to int main() and have the program return 0. 4. Replace getch() with cin.get(). See this thread... http://www.daniweb.com/software-development/cpp/threads/11811/replacement-of-getch | |
Re: You have to supply a size, but it can be a "best guess" and you can always reallocate later if the guess was wrong. If it's user input from the console, I imagine a buffer of 100 would probably do the job without reallocation in most cases. | |
Re: Add me to the people who can't reply to any message ever with IE 8. Now that I understand that's what the issue is, I'll just use another browser. Just replying FYI that for me it's been every single time over a space of days, so I doubt it was … | |
![]() | Re: Who the hell would pay attention to a Rugby Tournament the day before the Super Bowl? Ask me Monday. |
Re: It's like a lot of things. Too many choices! Computer Science is such a rapidly evolving field with so many niches, you'll never learn it all and that's OK. Pick something that you are interested in and study that. For example, I have a friend who loves gaming and so … | |
Re: [quote] >>#define p printf >>#define s scanf Horrible misuse of macros. Don't be so lazy and just type out the word printf and scanf when needed. [/quote] Amen. | |
Re: >> Hmm....is that allocating the size of a pointer to a char instead of the size of a char Well, sizeof doesn't allocate anything, but combined with malloc, yes you're allocating memory for 30 pointers, not thirty chars. I'm confused by line 16... [code] char** dictionary[words]; [/code] I can't tell … | |
Re: You might need to expand on what the user input options are and what needs to be done in different circumstances. You give "insert 3", but it sounds like there are other options as well. what are some of the other options? | |
Re: How much time do you have? [url]http://www.daweidesigns.com/cgi-bin/pointers.php?page=3-0[/url] One is a pointer, one is an array. That pointer might potentially point to an array or it might not. In some cases a pointer can be used as if it was an array and in some cases it most definitely cannot. | |
Re: The first step in tracking down the problem would be to get more information on point number 3. [quote] 3)Finally, when attempting to access a specific value (within range) within a vector,I also get a crash.[/quote] If it's truly "within range", I don't see how it can crash. How do … | |
Re: [code] void Shoppingcart( string ); //constructor [/code] This isn't a constructor. If you think this is a constructor, you need to take a tutorial on classes, then come back to this. [code] int ShoppingCart::setStore( int pluCode, string prodName, int prodType, double unitPrice, double inStock) //constructor [/code] Neither is this. See … | |
Re: I would change a few variable names, sticks some prepositions in there, or something like that. The variable names, while descriptive, aren't descriptive enough. I want to be able to read the probram and figure out whether the math flows correctly, but TilesBoxes could mean NumBoxesOfTiles, NumTilesThatFitInAInASingleBox, NumTilesInBoxes, etc. It … | |
Re: >> I am however getting linking errors such as-->[Linker error] undefined reference to `Database::AddStudent()' That's actually the one error you SHOULDN'T get. Are you sure you're getting it? Look at AddStudent. That's the one function that is correct, so model the others after it. The rest of them are wrong. … | |
Re: | is "bitwise OR". |= is bitwise-or and an assignment operator, just like +=, -=, %=, etc. Very often you'll have "boolean" type flags. My guess is that that is what WS_CHILD and WS_VISIBLE are. "ORing" them sets them as true, so I imagine ORing the WS_VISIBLE option means "make … | |
Re: >> So far my code is counting all multi-letter words but not single letter words Try changing "a" to "ab" or any other multi-letter word. I see no difference in the count. Your problem is that you have used one test case and that test case has erroneously led you … | |
Re: Too vague to answer. What does "obtain the original values back" mean? You have a string and you can't extract the ASCII values? You can't display non-printable characters? The string is corrupted? You're not reading correctly from the serial cable? Etc.? | |
Re: If you can read it from a file, you should be able to read it from stdin, since stdin is a "file", as is everything. The question becomes, "How do I know when I am done?" You know when you are done in the file somehow. You need to have … | |
Re: Slight modification. Put the cout in the if statement. I'm a little surprised that it works since strings end with '\n' rather than '\0', but it did. You don't want to display that last '\0'. That seemed to be the problem. [code=cplusplus] #include<iostream> #include<string> using namespace std; void rev_str(string str,int … | |
Re: [QUOTE=Cosa;592794]I am having trouble devising a method to multiply 2 matricies that are formed by dynamic one dimensional arrays, for this case i just used matrix1 and matrix2 To access elements that are on rows 0 to n-1 in either matrix i have to use this method: ((rows - 1) … |
The End.