1,288 Posted Topics
Re: There's no great trick to algorithms. You just have to work out how you'd do it yourself and then code that. So, you have gathered five numbers and you need to see which is smallest. Look at the first number. That's the smallest one you've seen so far ([B]smallestNumber = … | |
Re: [B]47 " no matching function for call to `Menu::Menu(const char[7])' "[/B] This is caused by the line [B]Menu soccerClothesMenu("soccer");[/B] The problem here is that you're calling a constructor to create a Menu object, but there is no such constructor. I see you have a constructor that takes a std::string and … | |
Re: [CODE]#include <sstream> #include <iostream> int main() { float i = 5.2314; std::string s; std::stringstream out; out << i; s = out.str(); std::cout << s; return 0; }[/CODE] | |
Re: [B] while (userChoice == 'A'||'D'||'S'||'P'||'Q'||'Z')[/B] This will always, always come up true. I suspect you meant: [B] while (userChoice == 'A'||userChoice == 'D'||userChoice == 'S'||userChoice == 'P'||userChoice == 'Q'||userChoice == 'Z')[/B] It still makes no sense, however. You are testing the value of userChoice at the start of the while … | |
Re: [B]Status.health - 20;[/B] This line makes the processor calculate the value of Status.health - 20.... and then do nothing with the number it has calculated. If you want to [I]change[/I] the value of Status.health try [B]Status.health = Status.health - 20;[/B] | |
Re: [url]http://www.cplusplus.com/forum/articles/28558/[/url] Go on, go to graphics :) | |
Re: 0xFEEEFEEE is used by Microsoft's HeapFree() to mark freed heap memory. This would seem to indicate that you are freeing memory (for example, as part of delete), and then trying to use it anyway. I understand that you can run in debug mode; if you run it in debug mode, … | |
Re: [QUOTE]when i am calling insert function it's not even entering into it as it's not printing the cout statement at first line of insert body.[/QUOTE] It [B]does[/B] enter that function. The buffer does not flush straight away. If you add an endl to the end of line 19, you'll see … | |
Re: You could stick an if statement in front of the cout. [B]if (number < 1000) cout<<....[/B] | |
Re: [B]if(((x1||y1||x2||y2)<=2)&&((x1||y1||x2||y2)>=0))[/B] If x1, y1, x2 and y2 are all zero, this says: [B]if (FALSE <= 2 && FALSE >=0)[/B] If any are not zero, it says [B]if (TRUE <=2 && TRUE >=0)[/B], I doubt that's what you meant. Read this [url]http://www.cplusplus.com/doc/tutorial/operators/[/url] | |
Re: Depends on how you made the linked list. If you don't like arrow operators, though, you can dereference the pointer explicitly, like so: [B](*a).something[/B] is identical to [B]a->something[/B] | |
Re: The compiler and linker have various options. Your project settings control what options are used. Release and Debug use different sets of options. Debug will choose options such as including debug symbols (to make debugging easier) and less (or no) optimisation. Release will typically not include debugging symbols and will … | |
Re: [B]node *new1= malloc(sizeof(node*))[/B] means make a pointer to a node. Call this pointer new1. Make it point to a lump of memory. Make that lump of memory the size of a pointer. Do you understand the difference between a node and a pointer (or indeed, an int and a pointer, … | |
Re: Nothing inherently wrong with using the switch statement like that. The following works (excuse the C++). [CODE]#include <cstdlib> #include <iostream> #include <cctype> int main() { switch(toupper(getchar())) { case 'U': std::cout << "It's you!"; break; default: std::cout << "Not"; break; } return 0; } [/CODE] | |
Re: [CODE]//Check For Dynamic Memory Allocation if (pCDROM1 == NULL) { cout << "Dynamic Memory Allocation FAILED" << endl; }[/CODE] When [B]new [/B]fails, it does not set the pointer to NULL. It throws an exception. There [I]is [/I]a nothrow version of new that will return NULL. [url]http://www.cplusplus.com/reference/std/new/operator%20new/[/url] | |
Re: [CODE]#include "stdio.h" #include "stdlib.h" int* someFunction(void) { int* array; array = (int*)malloc(100 * sizeof(int)); array[0]=10; array[1]=54; return array; }; int main() { int* array = someFunction(); printf("%i %i", array[0], array[1]); free(array); return 0; } [/CODE] or in C++... [CODE] #include <iostream> int* someFunction() { int* array = new int[100]; array[0]=10; … | |
Re: Your question makes no sense. HTML is plain text that is interpreted by a suitable programme such as a web browser. C++ is plain text that is turned into a programme using a compiler. They are completely different things and writing a C++ programme for the purpose of generating HTML … | |
Re: For any given task, there is no one "best" language. The list of things that might make a language choice better than another is huge; programmer knowledge, existing libraries, contractual obligations, religious beliefs, on and on and on. That said, C can certainly handle such things. If you want to … | |
Re: These issues are all about you passing single char (or a pointer to char) into functions that expect other things. Your code looks a little confused to me. [B]int getNumberAliveNeighbors(char myArray[][numRows][numColumns]);[/B] What do you actually mean to pass into this function? | |
Re: This is a piece of C++ code. This code defines a new type; the type is a struct, named Context. The code then defines the default constructor Context() for this new struct. You do not have to define a default constructor for a class or struct; if you do not, … | |
Re: The function you're looking for is called [B]pow[/B]. It lives in <cmath> | |
Re: [CODE]for(char next=0; next<=6; next++) { next=+10; }[/CODE] So you create a new char called next (presumably shadowing the one you already had called next, so you're not changing that one at all), and then add ten to it, at which point the value is greater than 6 so the for … | |
Re: Sleep is not part of the standard. Your system may or may not include it. If you're using windows, try [CODE]#include <windows.h>[/CODE] and use Sleep with a capital 'S'. If you're using a unixlike [CODE]#include <unistd.h>[/CODE] and use usleep. | |
Re: C and C++ do not have anything to do with GUIs as part of the language. No messageboxes. No datagrids. No buttons. No listviews. Nothing. All of those things depend on the hardware and the operating system, and C and C++ try hard to be independent of hardware and operating … | |
Re: To reach the point of being able to write and run a C++ program, you need three things. A text editor to write the code, a compiler to turn the text files into object files, and a linker to tie the object files together into an executable or library. If … | |
Re: This code shows creating an int, creating a pointer to it, creating an array of pointers, storing the memory address as a plain int, and then using that plain int to get back the contents of the memory address. It's C++ code to make outputting the values easy; the important … | |
Re: netdb.h is part of the standard Unix (and indeed, Linux and various BSDs). If you're using windows, then you also don't have the library it uses, so even giving you a copy of netdb.h won't help. Windows uses the WinSock networking library instead. | |
Re: A header file is just like a cpp file. It's just code. Plain text. Nothing more, nothing less. It's used by the compiler to make the actual program. I'd be very impressed if you could write a C++ program without any text files. Frequently, we write code that we like … | |
Re: When a=5, you are trying to read and write x[5][0]. This is not your memory and your code segfaults. Change [B]for (a=0;a<=5;a++)[/B] to [B]for (a=0;a<5;a++)[/B] in both sets of loops. When you ran your code, it should have crashed and you should have seen an error message indicating that there … | |
Re: [QUOTE]I was under the assumptions strings are pass by referenced automatically. [/QUOTE] They are not. [QUOTE=bennetk2;1660695]How would I return things then? Suggestion or example for one.[/QUOTE] In this case, you don't need to. You are passing in a pointer to the string you want changed, so the changes are visible … | |
Re: [CODE]extPersonType (string = "", string = "", int = 1, int = 1, int = 1900, string = "", string = "", string = "", int = 0, string = "", string = "");[/CODE] What are you trying to do with this line of code? | |
Re: Here is one such FM for you to read :) http://www.cplusplus.com/reference/clibrary/cstdio/printf/ Here's a simpler version. http://www.ehow.com/how_2066123_use-printf-command-c.html | |
Re: If you want different programmes to communicate with each other when they're running at the same time, you need interprocess communication. [url]http://en.wikipedia.org/wiki/Interprocess_communication[/url] If you actually mean different cpp files into one programme, you need to compile each cpp file into an object file and then link them together with the … | |
Re: Your code is fine. The problem must be with Dev-C++. I suggest you use something better. Dev-C++ has lots of problems and there are far better alternatives. | |
Re: C and C++. a[-1] is valid syntax. | |
Re: [url]http://www.cplusplus.com/articles/4z18T05o/[/url] | |
Re: Your do-while loop will never, ever end. Every time you get to [CODE]while (c='\n');[/CODE] c is made to equal '\n', which always evaluates to true. So, after the first time, you have made c equal to '\n', and the loop goes round again, and presumably that time goes to the … | |
Re: [QUOTE]undefined reference to `addus'[/QUOTE] The linker cannot find the function addus. This is not a compile error - it is a linking error. Your assembly code needs to be turned into an object file, and linked against. | |
Re: [url]http://cplusplus.com/articles/1w6AC542/[/url] | |
Re: Under windows, the system function is "system" and the format command from the command line is "format". Thus, [CODE]#include <ctsdlib> int main() { system("format a: /v:noLabel"); return 0; }[/CODE] [url]http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/format.mspx?mfr=true[/url] This is a very clumsy way to automate a command line programme such as format. You'd be better off looking … | |
Re: Your if statements look very confused. This, for example [B]!("black" || "gold" || "silver" || "brown" || "red" || "orange" || "yellow" || "green" || "blue" || "violet" || "gray" || "white")[/B] gives boolean false every time, so your line [B] if (Color[2] == !("black" || "gold" || "silver" || … | |
Re: Didn't this already get discussed at length? [url]http://www.daniweb.com/software-development/cpp/threads/384193[/url] | |
Re: Add each cpp file to the project, and they will be linked together and will be able to use functions from each other. | |
Re: This gives the address of an instance of the structure named [B]one[/B], of type [B]breakfast[/B]. I just need to know the name of it - [B]one[/B]. [CODE]#include <iostream> struct breakfast { int eggs; int beans; }; int main() { breakfast one; std::cout << &one; return 0; }[/CODE] | |
Re: This is defining a custom data type; a structure of type NUMBERS. This newly defined data type contains two sub-objects. This first of these sub-objects is an array of [B]char[/B]s, labelled "name". The array is MAXCHARS long. The second sub-object is a pointer named value. It is a pointer to … | |
Re: [url]http://beej.us/guide/bgnet/[/url] Scroll down, pick preferred format. | |
Re: If you can draw it at 45 degrees and -45 degrees, can you also draw it at 44 and -44 degrees? And all the angles inbetween? How about something as simple as this: Draw it at 45 degrees. Wait a tenth of a second. Draw it at 44 degrees. Wait … | |
Re: 2/3 equals zero because they're integers. Try using 2.0/3.0 | |
Re: I second that. It's not just a good C book; it's one of the finest programming books ever written. Also grab a copy of the ISO C standard as a reference manual (and because C has changed a little here and there since K&R's magnum opus). |
The End.