1,288 Posted Topics
Re: > after taking book name to a temp veriable, how can i pass it to setboob() member function `setboob(temp_variable);` | |
Re: The function is meant to return a void pointer. What are you returning? | |
Re: See that part of your code where you add the next term? Add the next term IF the next term is greater than 0.0001 | |
Re: Just to add to Mike's words on memory leaks, you're running this on a Windows machine, but if you were running on a \*nix, you could use valgrind to identify your memory leaks for you; granted, it's pretty easy in this case (a bazillion `new`, no `delete` - memory leak … | |
Re: Your code generates three different random numbers. One to compare to 50, one to compare to 100, and one to put in the array. Try this: for(int i = 0; i < 40; i++) { a[i] = rand()%(max-min + 1) + min; } where max and min are, in your … | |
Re: Do you know how to get one character from a string? http://www.cplusplus.com/reference/string/string/operator[]/ | |
Re: Lots. Do *you* have any code, or do you at least know how to do this on paper? | |
Re: Given that the code uses the C++ standard library and c++ only features such as templates, I rather suspect that this is making use of the g++ extension that allows VLAs in C++. It certainly won't compile as C :) | |
Re: If it's a single C++ file, can you simply create a new project in netbeans and copy the code across? This would be an excellent opportunity for you to learn how creatign a C++ program actually works, so that in future you'd be able to move your code around any … | |
Re: Add up all the hours, multiply by three, divide by the number of students. | |
Re: You could do worse than debugging it yourself. Something like this comes to mind: bool operator==(const person &lhs, const person &rhs) { cout << "Comparing lhs.name " << lhs.name << " to rhs.name " << rhs.name << endl; return lhs.name == rhs.name; } | |
Re: In what way is cout not working? Does the code compile? Do you get an error message? What do you see on screen? Does it run? Does the window it runs in close too fast for you to actually see what happens? Dev C++ 4.9.9.2 is a terrible choice. Throw … | |
Re: Here is how to check if a pointer is not NULL before using it: if (pointer != NULL) { // do something with the pointer } else { // don't do something with the pointer } | |
Re: Try lines 58 and 61 with an extra space in them, like this. 58: `scanf(" %[^\n]s",&newptr->item_name);` 61: `scanf(" %[^\n]s",&newptr->item_code);` Or even better, without the bad argument type, 58: `scanf(" %[^\n]s",newptr->item_name);` 61: `scanf(" %[^\n]s",newptr->item_code);` | |
Re: You are using one variable, `output`, to store the decrypted password. However, you are just adding each decrypted password onto the end of the last one in your variable `output`. This is bad. Each time you're finished checking a password, reset `output` to blank. | |
Re: There is no best game tutorial. That's an impossible demand. What do you want to do? Give us something specific that you don't know how to do right now that you want to do. Show an image? Show a 3D shape? Make a sound? Make a shape move on the … | |
Re: Line 24. You missed a `;` It should read `for(int i = 0; i < 3 ; i++)` | |
Re: This code shows a function `uniformSearch` that will search an array and will take a uniform amount of time, except if the array is really, really big. If that happens, you can increase the amount of time the search should take until it takes a uniform amount of time again. … | |
Re: Line 15. The vector `v` has no contents. It is of size zero. `max_element` returns the iterator that is `v.end()`. You then try to dereference this iterator, which is forbidden. | |
Re: What do you mean by "access" in this context? | |
Re: Are you sure it doesn't run? That output seems to indicate that it did run, and it finished with a return value of -1. | |
Re: Have you tried checking the value of the variable to see if it changes? That's a complete guess, but since you haven't actually asked any question, I've got very little to work with. http://www.daniweb.com/software-development/cpp/threads/78223/read-this-before-posting-a-question | |
Re: The standard C library function `strstr` can be used to search a string for a substring. | |
Re: As deceptikon says, they're different headers giving you different things. <string> gives you these capabilities: http://en.cppreference.com/w/cpp/header/string <cstring> gives you these: http://en.cppreference.com/w/cpp/header/cstring | |
Re: How far have you got? I note that you say you have to use doubly linked lists, but the assignment says singly linked lists. Which is it? Have you written down the actual things you need to do (i.e. do you understand the assignment)? | |
Re: > cout,cin,endl are no longer supported Really? I suspect that actually, your code is wrong. Alternatively, you've not told it you're trying to code in plain C++ (Visual Studio supports many languages). Possibly you're learning C++ from before 1990 and you're not using namespaces. Let's see your code. | |
Re: Do you need to do this using C++? This kind of thing is easily done with standard command line tools. For example, on many \*nix systems, `grep -c word_to_find name_of_file` does this quickly and efficiently. | |
Re: C++ doesn't have any built in graphics. There are moves afoot, heavily driven by Herb Sutter, to add graphics to a future C++ standard (C++ 17, perhaps). If you want to show somethig on screen, ultimately you ask the operating system to ask the graphics driver to do it for … | |
Re: What OS are you using? While there are many ways to do this using C++, the ubiquitous command line tool "grep" is literally made for this. | |
Re: If `Voltage_High` is of type float, then `&Voltage_High` is of type pointer-to-float. The fact that all pointers are the same size in memory is irrelevant. If you want to point to a float, you need a float-pointer; `float* pVoltage = &Voltage_High;` | |
Re: Are you struggling to come up with the algorithm to identify a semi-circle, given a set of contours, or do you have your algorithm and you're struggling to code it? | |
Re: `pointerToSomeObject->aMemberFunctionOfThatObject` is the same as `*(pointerToSomeObject).aMemberFunctionOfThatObject` `->` is just shorthand for "dereference this pointer, and then give me this member function/variable. | |
Re: Please help us to help you. What input do you give it, what output do you get,and how is that different from what you want? Is this intended to be a bubble sort implementation? | |
Re: When you run a program, it has what is knwon as a "working directory". This is the place you can effectively think of the program, as the name implies, working in. This is where it will look for files to open, by default. This is where it will write files … | |
Re: To debug this, build with debug symbols, set your debugger to watch the variable you are interested in, and when the variable is changed the debugger will interrupt the program and you can see what changed the variable. | |
Re: You do sound confused. If I point out to you that in C++, a struct and a class are identical except for default privacy levels, does that help? > But technically I want to use a struct as the template arugment, not a class. There's no difference. | |
Re: Your code never inserts a patient record. Your insert function never gets to line 146 because on line 138 you call menu(). | |
Re: The condition is checked at the start of the while loop. Then the contents of the while loop are executed. All of them. Changing the value of that condition during the loop has no effect until the condition is checked. When is the condition checked? At the start of the … | |
Re: `checkLength(length) == false || lowerCase(length, line) == false || upperCase(length, line) == false || beginLetter(length, line) == false || correctDigits(length, line) == false || specialChar(length, line)` When this is executed, from left to right, as soon as the final outcome is known for sure, all the rest will be skipped. … | |
Re: Ah yes, the perenial Ponzi scam. This forum is about a different kind of programming :p | |
Re: You're monitoring the default constructor, which is being used once. You're not monitoring the copy constructor as well. Add this to your class to see it: A( const A& other ) { cout<<"A copied"<<endl; } | |
Re: Your writefile function is fine. What makes you think it isn't working? It will create the file "results.txt" in the working directory. Have you looked in the working directory? This will (if you're using an IDE) probably not be the same directory that the source code is in. If you … | |
Re: `char *name[x];` This creates an array of char pointers. Each one is pointing to some random place in memory. `infile >> name[i];` This is an attempt to write over than random place in memory. Writing over some random place in memory is very very bad. If you make a pointer, … | |
Re: > Can u plz help why dis happens? You've spelt "you", "please" and "this" incorrectly. Many people here speak English as a second language and deliberately misspelling words while asking for help won't encourage people to help you. So your code goes through the if statement, and then the goto … | |
Re: Start at the beginning. > Write a program that prompts the user to input two positive integers Can you do this? | |
Re: **ex233(0 or less)** *does nothing.* **ex233(1)** outputs 1, calls ex233(-1), calls ex233(0), outputs 1. We already know about ex233(-1) and ex233(0), so this can be summarised as *outputs 1, outputs 1* **ex233(2)** outputs 2, calls ex233(0), calls ex233(1), outputs 2. **ex233(3)** outputs 3, calls ex233(1), calls ex233(2), outputs 3. Now … | |
Re: A header file is a text file. Just plain text. If you have a text file that you want to use as a header file, make sure it's correct C++ code, name it something.h, and then put it somewhere sensible, like next to your cpp files or in a separate … |
The End.