1,288 Posted Topics
Re: Where you read a line of text into the variable "line" (on line 31 of your code, above), don't. Instead, create a string for storing the shelf number, and a string for storing the item name, and then read in the shelf number ( `file >> shelf_number;` ) and then … | |
Re: If you really don't want to use a string object, you can read the file into your aray of char. It would be much better to use a string. http://www.cplusplus.com/reference/istream/istream/getline/ `myfile.getline(line, 120);` Using it as the condition in a `while` loop isn't going to work. | |
Re: You would start by identifying the operating system you are going to write it for. You then learn that operating system's (and possibly window manager) API for graphics. For example, if you were going to target windows, you would learn the Win32 API, perhaps by starting here: http://www.winprog.org/tutorial/start.html (that's been … | |
Re: An array is some objects of the same type all next to each other in memory. A linked list is a set of objects of the same type, each of which contains a pointer to the next one. They could all be scattered anywhere in memory. | |
Re: If you tell people what the error message is, they can tell you what it means. As it is, it looks like you have cut and paste your code three times, over the top of itself, so you've presented us with a complete mess. | |
Re: Because you're writing all your code in one project, you're trying to combine all your code into a single program. You're only allowed one function named `main` in a single program. Because you wrote lots of functions named `main`, you're breaking that rule. Separate project for each exercise. | |
Re: If you already have the class, you could do worse than simply change your existing code into template and see what happens. If you class, for example, looks like this: class Numbers { private: int theValue; public: int getValue(){ return theValue;} void setValue(int input){theValue = input;} }; you could just … | |
Re: There's no data there to store. Every BREAD object is identical to every other BREAD object. There's nothing to serialise. | |
Re: You see that `do` on line 213? Where is its matching `while`? | |
Re: If you read them in a piece at a time and overwrite the piece each time, you can make that piece as small as you like | |
Re: `#include` the header(s) so you can compile it, and tell the linker to link against the binary library file so you can link against it. | |
Re: `cin.clear()` resets the error flags, but does not empty the buffer, so next time round the loop, there's already something in the buffer. You can use `cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');` to empty the buffer (requires `#include <limits>`). There are other options too. | |
Re: The very simple algorithm for finding x is shown at the right of the Wiki page: http://en.wikipedia.org/wiki/Quadratic_formula | |
Re: `else if (X=Y)` In C++, `=` is the assignment operator. `X=Y` means "make X have the same value as Y". The operator you want here is `==`. | |
Re: If your aim is to use existing libraries, you need to know almost nothing about how they were made. The point of a library is that someone else has already done all the making for you, so that you don't need to worry about the details. All you need to … | |
Re: You can expect to get a segFault when you try to read or write to memory that the operating system thinks does not belong to that program. So if you have an area of memory allocated to your program, and your array is somewhere inside that area of memory, what … | |
Re: THe class variable named `city` is a `char`. A single `char`. It can hold one letter. Just one. It cannot hold Kyiv, because Kyiv is four letters. Change it to a `string`. THe class variable named `country` is a `char`. A single `char`. It can hold one letter. Just one. … | |
Re: You need to link against the library that contains the function moveto, setbkcolor, setcolor, linerel, grapherrormsg, graphresult, initgraph. | |
![]() | Re: This line ` cin >> ov.Rock;` in your main function calls the operator function `istream& operator>> ( istream& is, RockName& name )` That function contains `is >> ov.Rock;` which calls the operator function `istream& operator>> ( istream& is, RockName& name )` which contains `is >> ov.Rock;` which calls the operator … ![]() |
Re: What is WriteModel()? It's not standard C++; it must be some function you got from somewhere. What is it? | |
Re: `} while (!input==1);` In C++, the not-equals logical test is `!=`, so try `} while (input!=1);` Anyway, you're testing the variable `input`. But you never change that variable. What is the variable `total` for? It's useless here. Remove it, and do your division operations on `input`. | |
![]() | Re: I think this might be what you're trying to do. Note that in your code, you wrote declarations for the overloaded operators, but you didn't actually write any code for them. #include <iostream> using namespace std; class Temp{ double fTemp; public: double FahrToCelsius(){ return (fTemp - 32.0) / 1.8; } … ![]() |
Re: http://www.thecrazyprogrammer.com/2013/01/download-turbo-c-for-windows-7-for-free.html I assume you're being forced to write programs for a 16bit DOS machine in the year 1990. If you ever have to write programs for modern computers, you'll need to change your tools. | |
Re: In your function `sendToDisplay`, the object named `digits` is a single int. So what are you trying to do here: `digits[i]` ? `Digits` is an int. Not an array. Likewise for `value`. `value` is a single char. Not an array. | |
Re: Within a class' member functions, you can use that class' member variables directly. That's simply how classes work. The function `CTime_24 CTime_24 :: operator+(int seconds)` is a class function of the class CTime_24, so you can directly access the class' members. Accessing a class' members by getting a pointer to … | |
Re: Build it with debugging symbols inserted, and then run it under a debugger. The debugger will show you the line of code it crashes on and allow you to examine the variables to see what the problem is. | |
| |
Re: Open input file. Get each word one at a time. If word == A: Get the next word v = that next word | |
Re: By reading the design documentation, or reading the source code. | |
Re: The code does not all have to be on one line. https://isocpp.org/wiki/faq/inline-functions#inline-member-fns | |
Re: You seem to be trying to declare a function, `pow`, twice. You also never define it. Anyway, it's complaining about this line: `cin>>a1>>a2>>a3>>a4;endl;` What is that `endl` for? | |
Re: Here, you set the variable total: int numdQuotes = 0; int total = numdQuotes/2; This sets it to the value 0, because at this moment, `numdQuotes/2` is zero. Your code never touches the variable `total` again, so it remains zero forever, so when you output it to screen, it's zero. | |
Re: Good for you. Well done. Here are some problems with it: Line 2 - conio is a non-standard header and using it comes with risks. Modern typical PC systems do NOT come with anything named conio, so by using it you're already restricting yourself. Don't use it. Line 3 - … | |
Re: It means you have to show us the file named `final project uts.cpp` Make sure you don't miss out line 41. | |
Re: Instead of `if (menu_selection==a)` try `if (menu_selection=='a')` You don't need to create varables named a, b, c and d on line 40. While I'm here, `void main()` is wrong. In C++, `main` returns an int. Always. There is no option. In C++, `main` returns an int. If your compiler lets … | |
Re: The biggest problem with the code here (apart from the spelling mistake on line 2 of the header file) is that you're creating a pointer-to-a-rectangle like this (remember that `new` creates an object on the heap memory, and gives back a *pointer* to that object): ` new rectangle(3,4);` and then … | |
Re: The short answer is you can't (without doing some more work). See that string you typed, "monday"? That does not exist once the compiler is finished. It's in your source code, typed in with all the other things you typed, but in the finished program there are no strings "monday", … | |
Re: You need to loop over every char in the string. Subject each char to the function `is_vowel`. Count how many times the function comes back as true. Return that total. | |
Re: Is that everything it says? I most commonly see that error with an undefined symbol, but in those cases it should say which symbol is undefined. Alternatively, it's trying to create a file somewhere that it does not have permission to, and then when it looks for that file, it … | |
Re: On a typical \*nix installation, `ldd executableName` will give you a listing of the dynamic libraries it uses. | |
Re: That builds and runs fine. My guess is that it finishes very quickly because it can't find the datafile and you don't even realise it ran and finished. | |
Re: What input do you give it, what output does it give back, what is it about the output that do you not like? If you're going to use floating point values, you need to read this: http://floating-point-gui.de/ If you're going to use floating point values for financial information, you need … | |
Re: The mean of the numbers 3123, 1412 and 2412 is 2316 (not 1414), and the variance of them is also not what you stated. Are you using some alternative definition of these terms? | |
Re: I have no idea what your code is trying to do. > the longest sequence the number has within the 2-number range What does that mean? The entire set of numbers is a sequence, and every subset of the numbers is a sequence. | |
Re: `carry_bits |= ((a & mask) & (b & mask)) << 1u;` When a is 1, `a & mask` is 1, or in binary 00000001. When b is 1, `b & mask` is 1, or in binary 00000001. So `((a & mask) & (b & mask))` is` 00000001 & 00000001`, which … | |
Re: Unless I'm reading this wrongly (because you have written this in a somewhat odd style with more layers of pointer redirection than you need), you are allocating enough space for 2 int values, and then trying to store ten int values in that space, so you're writing over eight int … | |
![]() | Re: Just copy the data. sStruct1 first; sStruct2 second; ... first.Base1 = *(second.Base1); first.Base2 = *(second.Base2); first.Base3 = *(second.Base3); ... *(second.Base1) = first.Base1; *(second.Base2) = first.Base2; *(second.Base3) = first.Base3; |
![]() | Re: If you're only allowed to use if statements, what is the meaning of `arrange these numbers`? You have no way to move them around into an order, because they're not contained in anything, so when you say "arrange" what do you mean? How do you know you can't use an … |
The End.