1,288 Posted Topics
Re: Your setWidth and setHeight functions have paths that do not return anything. That doesn't seem to matter since you never call these functions anyway. You never set the width and length of rectangle [B]a[/B]; not even to default values. They could be anything. What are the rectangle class variables [B]x[/B] … | |
Re: I suggest using easybmp. It's very easy. [url]http://easybmp.sourceforge.net/[/url] | |
Re: An array is just many of the same object next to each other in memory. A vector is a proper C++ container class with an accompanying set of functions for interrogation and manipulation, able to manage its own resources, and to which numerous other C++ facilities such as the algorithms … | |
Re: Keeping track of vehicles parked in a garage. The garage is an object. It can contain a variable number of vehicles. Each vehicle is an object. | |
Re: When you enter the second number (y) as 0, this line: [B]printf("\nThe Quotant of %d and %d is: %d.",x,y,x/y);[/B] attempts to divide by zero. This is bad and it makes your program abort execution. I see that your code contains a logic check for [B]y[/B] being set to zero; unfortunately, … | |
Re: Did you actually mean this? It produces quite different results: [CODE]main() { char *p="dcis"; while(*p++!='\0') printf("%s",p); }[/CODE] | |
Re: The order in which they are to be evaluated is not defined by the language definition. Therefore, it is [I]un[/I]defined. | |
| |
Re: Dev-C++ is a bad idea (at least, the one from Bloodshed is). Read this, pick something better. [url]http://www.cplusplus.com/articles/36vU7k9E/[/url] What's this it says halfway down the page? [B]Be careful doing this, though, as having two versions of MinGW might trigger linker errors ("undefined reference to __cpu_features_init"). [/B] That sounds familiar. | |
Re: [QUOTE]"#include <ctime>" tells the linker "look in the ctime library for functions." [/QUOTE] [B]#include[/B] does not tell the linker anything - it is an instruction for the preprocessor. | |
Re: [CODE] char*temp = a[0]; // make a new pointer, and point it at the char in a[0] strcpy(a[0],a[1]); // Overwrite the char in a[0] with the char in a[1], so now a[0] is 'b' strcpy(a[1],temp); // overwrite the char in a[1] with temp, which is the char in a[0], which … | |
Re: Here is how to define a class: [CODE]class nameOfClass{ // variables int x; string y; // functions int someFunction( float inputParameter); }; [/CODE] Now you do it for odometer class. | |
Re: [B]addEntry[/B]'s third parameter should be a string, according to the declaration of the function, but you're passing it a pointer to a string. Likewise [B]deleteEntry[/B]. | |
Re: Use GetLastError [url]http://msdn.microsoft.com/en-us/library/windows/desktop/ms679360(v=vs.85).aspx[/url] for more information. | |
Re: Is that not supposed to happen? If not, why did you code it that way? Read this [url]http://www.daniweb.com/software-development/cpp/threads/78223[/url] and ask again. | |
Re: [QUOTE]also want to end executing a function of type void without allowing it to end but don't know how.[/QUOTE] Stick [B]return;[/B] where you want it to end. | |
Re: [CODE] int main() { int a[10][20][30][40]; a[0][0][0][0] = 314159; a[0][0][0][1] = 1414; int *p = &a[0][0][0][0]; printf("%i \n", *p); p++; printf("%i \n", *p); return 0; }[/CODE] | |
| |
Re: [CODE]for (int counter = 1; counter <= ending; counter >= beginning; counter++)[/CODE] This is wrong. The [B]for [/B]loop takes only three statements in the brackets. I suspect you meant something like: [CODE]for (int counter = beginning; counter<= ending; counter++)[/CODE] [CODE]while (value <= ending; value >= beginning; counter2++)[/CODE] This is wrong. … | |
Re: To do so, you'd either have to use global variables (not good) or use [B]new [/B]and [B]delete [/B]to extend object lifetimes. A simpler way is to just use parameters in your functions. It's what they're for. [CODE] string inputsentance() { string sentance; cout<< "inputsentance"; cin>> sentance; return sentance; } string … | |
Re: Presumably you're not running it from console - you're pushing a button somewhere to make it run. As such, something else is opening a console window for you. When the program finishes, why would that console window stay open? [url]http://www.cplusplus.com/forum/beginner/1988/[/url] | |
Re: [url]http://en.wikipedia.org/wiki/Main_function#C_and_C.2B.2B[/url] | |
Re: [QUOTE]Is Directx efficient for GUI apps ?[/QUOTE] The short answer is no. DirectX is vastly overpowered (and consequently excessively low-level) if you just want to knock together GUI apps. The common approach is to pick a suitable widget toolkit for your needs and system, and use that. Here's a list: … | |
Re: Read this: [url]http://www.cplusplus.com/articles/EN3hAqkS/[/url] and then this: [url]http://www.cplusplus.com/articles/z186b7Xj/[/url] and then if you still don't se any use for them, come back and ask again. | |
Re: Don't use char arrays. Use a single array of C++ strings. Then use the sort function. [url]http://www.cplusplus.com/reference/algorithm/sort/[/url] Don't use [B]void main()[/B]. It's wrong. Use [B]int main()[/B] | |
Re: [code]static int Decode_VL64(const std::string &data){ char* chars = (char*)data.c_str(); return Decode_VL64(data); }[/code] This function will never, ever end. It's recursive. You're calling the function again at the end every time, over and over and over and over and over...... until finally the stack has no room left to call the … | |
Re: There is an issue in how you went about creating the array of char: [CODE]char * ptrNewBuffer = new char[STRING.size() + 1];[/CODE] At the point of creation of this array of char, what is the size of STRING? Later in the code, you will repeatedly attempt to copy a line … | |
Re: [B]undefined reference[/B] indicates that the compilation is fine, but the linking is not. Check which libraries you need to link against. Linking just against glut32.lib is not enough. | |
Re: I am sure we already solved this. [url]http://www.daniweb.com/software-development/cpp/threads/401547[/url] [QUOTE]It would be better a better if i have another solution,idea for the issue. [/QUOTE] We gave you a working solution. What's wrong with it? | |
Re: Very few target DSP processors support windows.h ;) I suspect easybmp would be relatively easy to port over to DSP. | |
Re: [B]I don't understand them at all.[/B] Do you understand what's meant by [B]A or B[/B] ? ![]() | |
Re: There are many, many many options. Here's a list: [url]http://en.wikipedia.org/wiki/List_of_widget_toolkits[/url] QT4 has a good reputation, for good reason. Have a look through the others as well and pick the one that best suits your needs and abilities. | |
Re: Unresolved external symbol generally means you've not linked to the right library, or you haven't written a function you need. The following code is fine. Can you build it? [CODE]#include <vector> #include <iostream> using namespace std; class CPiece { public: vector<vector<int> > piece; CPiece() :piece(4,vector<int>(2)) {} }; int main() { … | |
Re: What is the possible range of values for each of a,b,c,d? Zero to nine? If so, then this might do what you want. If you can guarantee that the type of array is [B]int[/B], it can be simplified. [CODE]array[i] = 1000 * a + 100 * b + 10 * … | |
Re: You are passing the function a copy of a pointer. That's what happens when you pass by value like this. A copy of the object is made, and given to the function. The function then changes that copy (note that you're not changing what the pointer points at; you're changing … | |
Re: [B]read from input file using C[/B] Did you mean C, or do you mean C++? You're using C++ (a very old C++ that will not work on modern compilers; looks like pre-standard C++ to me, as if you were using a decade old compiler... using Dev-C++, by any chance?) | |
Re: See this: [B](y1+y2)/2[/B] The answer to thins will be an integer, because y1 and y2 are integers and you're dividing by an integer. So if y1=0 and y2=3, the answer will [B]not[/B] be 1.5 If you want non-integer answers, you have to turn the input into double or float. | |
Re: Depending on the standard that the original coder coded to, you might be able to get away with very little work. Valid C code is valid C code, regardless of whether it's on *nix or Win32. The issues generally arise when libraries are available on one system and not the … | |
Re: A C++ compiler will happily compile the following code. [CODE]#include <iostream> #include "stdio.h" int main() { std::cout << "Hello "; printf("world"); return 0; } [/CODE] C++ is (almost) a superset of C. If it's valid C code, it's valid C++. The only time one has to be careful is linking … | |
Re: Change [B]file_ptr=fopen("C:\Dictionary","r");[/B] to [B]file_ptr=fopen("C:/Dictionary","r");[/B] | |
Re: [CODE]if (input == "%INSERT") { while(input != "%DELETE") { inFile >> nm; inFile >> num; cout << nm << num << endl; } }[/CODE] This looks like an infinite loop. You establish at first that input is %INSERT, and then you keep reading in for as long as input does … | |
Re: Are you simply trying to set the values? Here is how you would set the value of [B]newptr->title[/B] to that of [B]title[/B] [CODE]newptr->title = title;[/CODE] The rest are very similar. I suggest that since year and price inside your book object are not strings, that you actually make them an … | |
Re: So [B]value[/B] is a pointer, that is supposed to point to an object of type [B]Value[/B] (awful choice of name for your pointer, by the way; really, really awful - if you can't think of a better name, at least call it something that makes it clear it's not Value … | |
Re: [B]void main()[/B] is incorrect; if your compiler doesn't complain, throw it away and get a modern, better one for free. | |
Re: [QUOTE]That solved the problem, It turned out I needed to use pointers to solve the question[/QUOTE] Preferably references. Pointers are a waste of processor when you can use references instead. | |
Re: [CODE]while(random_temp != 17,18,19,20,21,22,23,24)[/CODE] That's just plain wrong. I suspect you meant: [CODE]while(random_temp != 17 && random_temp != 18 && random_temp != 19 && random_temp != 20 && random_temp != 21 && random_temp != 22 && random_temp != 23 && random_temp != 24)[/CODE] which can be more elegantly put [CODE]while(random_temp < … | |
Re: Firstly, void main() is non-standard. Just because it works using your current compiler on your current operating system in your current hardware is no guarantee that it will work elsewhere. Deliberately writing programs like this is foolish when you could just write [B]int[/B] instead of [B]void[/B]. Here is a page … | |
Re: [QUOTE]something like pass by reference[/QUOTE] I can only show you actual pass by reference, not something like pass by reference. [B]void function(char*&);[/B] | |
Re: [CODE]#include <iostream> int main() { char* p = "eggs on toast"; void* q = (void*) p; // to void*... char* r = (char*) q; // and back std::cout << r; return 0; }[/CODE] |
The End.