1,288 Posted Topics
Re: Ensure it really is called Motto.cpp Windows has a terrible habit of adding extra bits to the end of file names, and then hiding it from you; if you wrote Motto.cpp with a standard issue text editor, for example, it might be called Motto.cpp.txt | |
Re: Line 19. What is the value of `n`? Also, your function `fun` just plain doesn't work. That loop doesn't loop. The first time you get to line 21, the function finishes. | |
Re: No. Only free something you allocated using malloc. You don't use malloc, so don't use free. The problems. Firstly, you are returning a pointer from your function `toBin`. What does it point at? A local variable, made inside that function. The local variable shouldn't exist anymore once the function ends. … | |
Re: I think you might be trying to ask "How can I turn a string into a double?" http://www.parashift.com/c++-faq-lite/convert-string-to-num.html | |
Re: The first one is a warning rather than an error. You've got an object of type time_t and you're using it as an unsigned int. The second one; you are passing a pointer to a pointer (to a bSearchTreeType<elemType>), where it is expected that you pass just a pointer (to … | |
| |
Re: `while(term > limit)` At this point, the first time this line of code is reached, what is the value of `term`? Also, look at this section of code: int denominator=1; term=(1/(pow(denominator,number))); What value will `demoninator` have in that calculation, every time? | |
Re: What happens if you don't try to use the same pointer (i.e. don't use hwnd twice)? | |
Re: Do you know what `strcmp` does? `strcmp` is a function that accepts *char pointers*. You don't have char pointers. You have C++ *strings*. You can compare a C++ string like this: `if (response == "ok") ` echo "word was found in webpage"; This doesn't look like C++ code. *echo* is … | |
Re: No set size. If you need to know, you'll have to find out at run-time. | |
Re: This: int test = int_ary[rand()% ((0 + 16383)-8191)]; picks one value from your array or maybe from way off the end of your array (which has never been set), and makes the int `test` equal to that value. Why? Anyway, inside your loop, you are doing this, over and over … | |
Re: Add `cvWaitKey(30);` after line 35 and see if that makes a difference. | |
Re: Some of your objects don't seem to make a lot of sense. I see you have a `card` class. Let's look at that. Here are some of its internals: char suit[4]; int value[13]; So one card has an array of 4 `char`s, named suit, and also an array of 13 … | |
Re: Impossible is a big word. It would definitely be painfully complicated and would change some very fundamental ideas, though. Here's just one reason why. The compiler works on one translation unit (which you can roughly think of as one cpp file) at a time, and then forgets about it when … | |
Re: `cx[8]=1.0; cy[8]=-1.0;` cx[8] does not exist. It stops at 7. Same for cy[8]. You're doing too many iterations. You need to stop your loop earlier. | |
Re: If you actually have to swap them, there are ways to do it without using any more variables. My favourite is this: i ^= j; j ^= i; i ^= j; | |
Re: C++ and C linkage is different. http://stackoverflow.com/questions/12066279/using-c-libraries-for-c-programs | |
Re: What ideas do you have already? You must have at least one; tell us that, and we can go from there. | |
Re: You could have the user enter a string, and if that string is "QUIT" the programme exits, and if that string is a number, convert it into an int and return it, and if the string is something else, reject it and ask the user to enter a new input. | |
Re: > But, in Parser I can't seem to access the data member? In the constructor `Parser()`, you access the data member of the Parser object (named `f` in your code). You resized the data object of the object named `w`. That's a different object. ![]() | |
Re: There are many, many ways. Here's one. Being able to use existing libraries written by other people is a valuable skill; it gives you a lot more capability in your programs, and it exposes you to other people's code and other ways of doing things. It's also very encouraging to … | |
Re: Alternatively, if you just want to show pictures on the screen and you don't need fancy 3D wonder, you can use one of the many existing libraries or widget toolkits that make it much easier. | |
Re: When you enter the number 45, what gets stored in the variable `value`? Which of your switch cases handles that? Where is `case 45:` ? ![]() | |
Re: We need a question. What does your code do that you think it shouldn't do, or what do you want it to do that it doesn't do, or does it not compile, or something else? | |
Re: Do you know how to actually solve this, and you just don't know how to code it, or do you have no idea how to solve this? | |
Re: `Access violation reading location 0xccccccc0.` The popular compiler from Microsoft uses the value `0xcccccccc` to indicate a value on the stack that you never set to anything (i.e. uninitialised stack memory). The obvious conclusion here is that you are using a pointer that you never set to any value. Let's … | |
Re: What's the size of each value? Are these simple int or double or the like, or some custom class? If you're generating these values and then operating on them, writing them to a text file and then reading them back in again is massively expensive in time and pretty pointless. … | |
Re: As Pinku says, you need a new type. You have two options. Either you can use one of the existing libraries that handle types this large, or you can handle it yourself. I usually point people towards the GNU Bignum library, but others exist. If you decide to handle it … | |
Re: As Ketsuekiame says, be aware that there is no strict definition of "Debug mode" and "release mode". If your IDE provides these two modes, all it does it turn on or off a number of compiler options depending on which mode you pick; options chosen by someone else with the … | |
Re: I see you're not using the standard C++ vector template objects, but instead some other kind of Vector, presumably defined in `Vector.h` Without knowing what that object is, we can't tell you how to get int values out of it. | |
Re: Start with the number zero, and each time an object is created, add one. That's the logic. If you mean something like creating a class, and counting how many times an object of that class is created, put the functionality to do the counting inside the constructor and make the … | |
Re: When you say > what I want is to display in the following location C: \ Users \ abdelhalim \ Documents. do you mean you want to write it to a file in that location? | |
Re: What size is the array you make like this? `char NAME[];` So how much data can you write into it? | |
Re: We're not really into giving people complete answers here; we tend to help you fix it yourself. You say that your code is giving errors. Let's see the code! I would expect that your file reading code in its simplest possible form would look something like this: ifstream fileToRead("someFileName"); fileToRead … | |
Re: You're trying to make an iterator that deals with maps like this: `std::map<string, Object>` but your actual map looks like this:`std::map<string, Object*>` As an aside, one of the very useful things brought to us by C++11 is the auto keyword allowing you to make iterators something like this: `auto itr=_c.begin();` | |
Re: This is hardware dependent. Look at your PC. There are connectors on it. USB ports, maybe a parallel port and a serial port. Using C++, you can ask the operating system to set voltage values on those connectors. Some operating systems will only allow you to set it to low … | |
Re: The second constructor there is using an *initialisation list*. There's no difference in the final state of the object when it's finished. If any of your member variables were const, or references, the initialisation list would be the only way to set the values. It's also usually faster to use … | |
Re: You know there's only one way to know for sure which, on a given system, will run faster. Build them, time them. | |
Re: It works fine; the pointers are swapped in value. What error do you get? | |
Re: #include <stdio.h> int main() { printf("Fill the three up, and pour it into the five. Fill the three up aain, and pour it into the five until the five is full. You now have one unit of liquid in the three container. Empty out the five, put the one unit … | |
Re: CImg springs to mind. Here is a complete working program to draw a 500x400 image on screen, with one pixel set to green. It is C++, though; have you got your heart set on doing it completely in C? #include "CImg.h" #include <iostream> using namespace cimg_library; int main() { // … | |
![]() | Re: The compiler begins reading the code at the top, and goes downwards through it, once. When it gets to a function call, like this: `print(marks);` it has to *already know* what parameters that function takes, and what it returns. There are two ways it can already know this. Either you … |
Re: As a rule of thumb, a temporary object has no name and you can't get its address. So the string named `str` is not temporary; it has a name. In your second code, it looks like you've got an `int` object and you're trying to pass it to a function … | |
![]() | Re: Does mmcdonald's code above not work for you? Here's a minimal, complete messagebox example that works on Win32. Does it work for you? #include <windows.h> INT WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpCmdLine, INT nShowCmd) { int nResult=MessageBox(NULL, "An example of Cancel,Retry,Continue", "Hello Message Box!", MB_ICONERROR|MB_ABORTRETRYIGNORE); return 0; } ![]() |
Re: That code compiles without any problems. This suggests that the code you showed us is not the code you're trying to compile. | |
Re: What operating system are you working with? I'm guessing windows, but I should check. If so, this might be what you're looking for: http://dslweb.nwnexus.com/~ast/dload/guicon.htm | |
Re: Why not pass by reference? The std::string class comes with a number of class functions for modifying the string. Using those is the standard way to modify the string. | |
Re: This is a problem with you using your text editor. Try pressing the "insert" key on the keyboard. | |
Re: There are many opportunities in your code to enter the value 'y'; please tell us the complete input you typed in, what the output was, and what you expected the output to be. |
The End.