1,288 Posted Topics
Re: What happens if you rewrite lines 9 and 10 to use forward slash rather than backward slash? infile.open("C:/Projects/C++/infile.txt"); outfile.open("C:/Projects/C++/outfile.txt"); | |
Re: You can tell gcc specific directories to search for libraries with the -L switch, e.g. `-L/some/directory/that/you/know/the/library/is/in` On Linux, you don't have to bother doing all this yourself as there's a helpful expanding config to do it for you that you add to your gcc line; `sdl-config --cflags --libs` ( https://wiki.libsdl.org/FAQLinux#How_do_I_add_SDL_to_my_project.3F … | |
Re: In what way does it "not let you"? Does the keyboard refuse to accept any entry when you get to the operator selection? | |
| |
Re: You create a pointer, named `datas`. You don't set it to point at anything, so it's pointing at some random memory somewhere. You then pass the address of that pointer to your readwav function; a pointer to a float-pointer. The function `readwav` calls this `buffer` and treats it as an … | |
Re: Programming is thinking. How would you do this on paper? If I gave you two sheets of paper with writing on, and asked you to find the first difference, how would you do that? | |
Re: On line 27, you make `current` and `num` the same. So the condition on line 30 will never be true, and line 32 will never happen. Is the condition on line 30 the correct thing to be comparing? Shouldn't you be comparing something against `highest`? | |
![]() | Re: The obvious first response is don't build it on the heap. You're creating it and destroying it all within the function `change_registry_config`, so just make it on the stack (i.e. don't use `new`) and you don't have to worry about memory. |
Re: Line 26 is testing for zero. I suspect you meant `=` rather than `==` You could have found this by printing out the values of the array after you zeroed it, to check it was being set correctly at the start. | |
Re: int count; int distance; If you couldn't do that on your own, you really, really need to go right back to the beginning and start again. | |
Re: `graphics.h` was a header file provided, along with a library, by some compiler bundles back in the eighties and early nineties. It is not part of the C++ standard. It was something extra that some compiler vendors provided to customers, so they could do some graphics work on their computers. … | |
Re: **It was meant as a test.** Well, obviously this forum fails your test. Please give up here and try some other forum. | |
Re: I see people using Turbo C++ sometimes, but this might be my first spot of plain Turbo C in the wild :p For the history buffs, the last version of Turbo C was released in 1989, and made 16 bit executables for DOS. For those to whom that means nothing, … | |
Re: What happens if you run the actual binary using gdb? So don't start it with a shell script. Just run the binary. `gdb <binary executable>` and then `run` | |
![]() | Re: Are you reading this input from the keyboard, or from a file, or will it be presented to you as some data object? ![]() |
Re: Get a compiler that can deal with objective-C and start programming. If you're stuck on windows, the MinGW port of GCC handles objective-c, so long as you remember to get the optional objective-c bits with it. If you can use Linux or mac OSX, it'll be easier. What will you … | |
Re: Create two numbers. Call the first one number_of_spaces. Call the second one number_of_stars. Set number_of_spaces to zero. Set number_of_stars to five. Now output number_of_spaces spaces, and number_of_stars stars. Add one to number_of_spaces, subtract one from number_of_stars. Repeat previous two instructions until you're done. Welcome to programming. Programming is thinking. When … | |
Re: Start at the beginning. **Q1: Write a for loop to fill-in the array with data.** So write a program that creates the array, and when that is working, add a for loop to fill the array with data. Do you know how to write an empty program that does nothing? … | |
Re: You've missed a semi-colon on line 11. Your `for` loop will go round 11 times instead of 10. Other than that, nothing. If you enter 11 marks you'll get an average mark. What makes you think it doesn't work? | |
Re: `printf("*\n***\n*****\n*******\n*********\n*********\n*******\n*****\n***\n*");` | |
Re: In C++, the `main` function doesn't go in a class. Maybe you're thinking of Java. | |
Re: All three do the same thing. They look at every element in the array, one at a time, and stop when they find the value you're looking for. You have removed a little bit of loop overhead from the second, and a little bit more of the loop overhead from … | |
Re: Here is a thread you should read that will enable you to ask a better question. https://www.daniweb.com/software-development/cpp/threads/470006/c-graphics-problem | |
Re: ` strVec.push_back(getline(about));` In that line of code, what is the variable `about`? It does not exist. | |
Re: Have you tried reading some books and writing some programs? That often helps. | |
Re: Is there an error message? Does it compile? Does it crash? Does it not do what you think it does? | |
Re: Line 12 makes no sense. vector::size() is how to ask a vector what size it is. It is *not* how to set the size of a vector. Line 16 serves no purpose. Your internal vector object will be destructed without you having to do anything. Your setElement function changes the … | |
Re: The page table has 2^20 entries. Each entry takes 4 bytes. So the page table is 4\*(2^20) bytes in total. You can write 2^12 bytes on a page. So how many pages do you need to write out the entire page table? (size of page table) / (bytes per page) … | |
Re: In your `main` function, you are using `r` and `v` as parameters to a function (line 18), but your main function does not know what `r` and `v` are. Did you mean `resistor` and `volts`? | |
Re: Can you copy a single file onto the computer? No installation needed, no installer to run, just a single header file? | |
Re: I see that in your setter function, there is no checking or processing; it simply sets the private variables to whatever the parameter says. In this case, there is no point in having them private; you might as well make them public variables, and then you won't need setters or … | |
Re: C++11 will do it, but will cast the parameter to double first. | |
Re: Without looking into if `std::string` does anything clever, I have a memory that as you add to it, it will keep expanding its capacity, but it will not give up that capacity unless specifically asked to; if you reduce the number of letters of what you're actually storing, all the … | |
Re: You seem to be writing your code in a version of C++ from about 20 years ago. A modern compiler doesn't recognise `<iostream.h>`, and a modern compiler uses namespaces, which you're not doing. Let me guess; you're using Turbo C++ from about 1993, and you have had to force Windows … | |
Re: The only way to know for sure is to profile the code and identify the hot spots. When trying to improve performace, it is very, very, very, very common for a hunch or guess to be just plain wrong. Bang out the performance profiling tools (on linux, I cannot recommend … | |
Re: ` virtual ~Deck():` Should that be a semi-colon? m_Deck.Deal(m_House); ) Should that final `)` be a `}` ? `m_house.FlipFirstCard();` Case matters. There is more. Fix the above, see if the new errors are helpful to you. | |
Re: Long story short, you ask your operating system to do it for you. You can ask directly by learning your operating system's API. You can ask indirectly by getting a widget toolkit; you ask the toolkit, and the toolkit asks the operating system for you. As a very strong general … | |
Re: Undefined reference means that the linker cannot find the compiled code for those functions. Where did you write those functions? Presumably in some \*.cpp file. Either those functions do not exist (wrote declarations, didn't write the actual functions), or you haven't compiled the file containing them, or your linker has … | |
Re: That's already C++. You could improve it by removing the `struct` keywords, passing references instead of pointers, not using `mh` and `tym` (ugly global variables), making your `particle` and `machine` types use proper C++ containers (which know their own size) instead of arrays, and using a modern C++11 random number … | |
Re: ` for (;;)` This will loop until you `break;` from it. So `break;` at the top level of the loop (i.e. not from within something else inside the for loop) where you want to stop looping. | |
Re: http://www.cplusplus.com/doc/tutorial/basic_io/ | |
Re: `char choice = 'a'; 'p'; 's'; 'q';` Let's take a look at this line. It creates a `char`, named `choice`, and then gives it the value `a`. All the rest of the line does nothing. It's jsut you saying letters. 'p'; does nothing,` 's';` does nothing, `'q';` does nothing. I … | |
Re: Given two characters (a-z, A-Z) in the ASCII character set, setting the sixth bit high will make it lower case if it was upper case, and do nothing if it was already lower case. Here's an example with "A". 32 = 0b0100000 A = 0b1000001 32|A = 0b1100001 = "a" … | |
Re: ` Curricuum(char *new_name, int *new_year, int new_count)` The second paramter here is an int-pointer. Not an int. ` Curricuum c1("Andriy Luchko", 1996, 0);` Here, you are trying to call the constructor using an int as the second parameter. The constructor is expecting an int-pointer. | |
Re: By looking at the algorithm and reasoning about the effect changing the variable workload has on the time taken. | |
Re: Your `ackermann` function is recursive (I don't know if it's correct, just that it's recursive), and calls itself so many times that you run out of memory on the stack. The solution is to come up with a way to make it a lot less recursive, or increase the stack … |
The End.