560 Posted Topics
![]() | Re: Google "Dynamic Memory Allocation C++" [code] int bufferSize = 512; char *buffer = new char[bufferSize]; strcpy(buffer,"This fits in my buffer."); //When finished you must delete the memory //or it will be a memory "leak" delete [] buffer; [/code] ![]() |
Hi, I'm starting to do some work with MFC and I was wondering why the design view seems to only work for dialogs? I'm using VS2010, is there a design view you can use with a simple SDI application? | |
Re: Not using Dev-C++ is a good idea. There are plenty of free compilers available, and if you're using Windows I would recommend Visual Studio 2010 express. The reason Dev-C++ is bad is because it's old, unsupported, and buggy. [url]http://www.microsoft.com/express/Downloads/[/url] Basically the problem with your code is that you haven't implemented … | |
Re: [url]http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx[/url] I don't think so. There are three events listed, Disposed, FileOk, and HelpRequested. I'm not real sure this is the best idea, but you could try deriving a class from SaveFileDialog and implement your own behavior. Another opinion on this idea would be good. | |
Re: "::" is the scope resolution operator. namespace::class is the form of std::string. | |
Re: I'm not extremely familiar with the Gauss-Seidel method, but typically you will want to use a setup like this when working with a matrix: [code] for(int row = 0; row < rowMax; row++){ for(int col = 0; col < colMax; col++){ matrix[row][col] = blah; } } [/code] Most C++ text … | |
Re: You can concatenate the C++ string class with the + operator though. | |
Re: I think you may experience link errors with your current setup. You need to have the code inside the header file for templates (no source file, header only). Truthfully you can include the .cpp file at the end of the .h file, but if you're using Visual Studio you will … | |
Re: lol. You could try making a program to either compress a file, or a program to split a file into pieces. The reason you may want to split a file into pieces could be it needs to fit on a FAT32 file system and is larger than 4 GB. You … | |
Re: If you can share files you can probably do it with two systems & a lan cable, but you will probably want to try it across the internet, if that's how it will be used... Obviously most internet connections are MUCH slower than the connection between two computers via a … | |
Re: Try changing your project options to not use unicode. LPCSTR = Long Pointer to a C-style STRing C = char * Microsoft typedefs their actual types, and if your project options are set to use unicode a different typedef is used for supporting unicode. (it may be LPCWSTR) You can … | |
Re: A pointer is probably the same size as an integer, so you probably won't gain any resources by using pointers when passing simple integers, but take a structure for example. (C++) [code] struct SomeType{ int x; int y; char name[128]; float delta; std::string etc; }; [/code] If you use a … | |
Re: Are you sure all those strings fit into 19 characters? (at the beginning where you use strcpy) You are using C++ so I might suggest a more flexible way of storing a string, specifically the C++ string class. [code] #include <string> int main() { std::string input = "Whatever length you … | |
Re: We can't help you unless you tell us the problem. It's entirely up to you to decide how your application works, unless you want me to write it, but then it's not really your application if you get my drift. I'm not really sure what "stats feed" you really mean … | |
Re: Step 1. [b][i]It's a base class because you're going to be deriving other classes from it.[/i][/b] Create a base class called Vehicle that has the manufacturer's name (type string), number of cylinders in the engine (type int.), and owner (type person given below instructions). Step 2. [b][i]Derive a class from … | |
Re: [i]function definition[/i] [code] void DoSomething(){ //something }[/code] [i]Function call[/i] [code] DoSomething(); [/code] | |
Re: This isn't a Visual Studio thing, but the home key group is your BEST friend. Home & end will move to the beginning and end of a line, page up & page down scroll pages at a time. Shift + (home || end) will highlight an entire line, Ctrl + … | |
Re: I think the 'object sender' is the control that generated the event, it could be a button on your form or the form it's self. The event args has more information about the event. Make a button on your form generate an event when clicked and try this: [code] Button … | |
Re: I'm not a 3D expert, but I would find an accurate timer, and use it. For instance, on Windows you could use this: [url]http://msdn.microsoft.com/en-us/library/ms724408%28v=vs.85%29.aspx[/url] or on this page, the section "The following functions are used with high-resolution performance counters." [url]http://msdn.microsoft.com/en-us/library/ms725473%28v=VS.85%29.aspx[/url] | |
Hey I'm making a small application for my gaming buddies, and I have a picturebox that I'm drawing on. The problem is, it appears as though the Location property of the MouseEventArgs is wrong, and it becomes even more so toward the bottom + right portion of the picture, like … | |
Re: [code] #include <string> #include <algorithm> int main(){ std::string text = "reversi mei!"; std::reverse(text.begin(), text.end()); } [/code] | |
Re: There is also a book by Wenbo Mao which may be worth your time. [url]http://www.amazon.com/Modern-Cryptography-Practice-Wenbo-Mao/dp/0130669431[/url] | |
Re: I think the application could be cool because if it didn't consume a lot of resources I would let it reside in my system tray, it could incorporate some other cool stuff too, like customizing notifications, etc. I think a Windows 7 style pop-up box telling me about some event … | |
Re: Hey those variable names don't look very descriptive, sometimes a meaningful name is helpful. | |
Re: We need to know about your "string array". | |
Re: Here's an even more-complicated way to print the contents of a string. [code] std::string inputFirst = "Clearly."; std::copy(inputFirst.begin(), inputFirst.end(), std::ostream_iterator <std::string::value_type> (std::cout)); [/code] | |
Re: I'm assuming you mean the mathematical kind of function, and finding the absolute maximum and absolute minimum, if they exist. Basically unless you want to parse some strings you can code the math function directly in a C++ function, such as this: [code] int ComputeValue(int x){ //f(x)= x + 3 … | |
Re: [url]http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/[/url] [url]http://www2.research.att.com/~bs/bs_faq2.html#int-to-string[/url] In C++, stringstreams are amazing. [code] template<class int_type> int_type stoi(const char *str){ int_type i = 0; std::stringstream(str) >> i; return i; } //You get the idea. [/code] | |
Re: I'm not sure what your teacher wants but some C++ library functions/algorithms can be used to simplify your code. It may be worthwhile to check out a C++ reference before and during your implementation. | |
Re: I think it means you need to create a separate class named "CarInsurance" as per your instructions, and all it has in it is the two variables, and the function. It will need to "throw" from inside the function, an ArgumentException, using "throw". [url]http://msdn.microsoft.com/en-us/library/1ah5wsex(v=vs.80).aspx[/url] [url]http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx[/url] : [code] throw new ArgumentException("Some … | |
I have a C++/CLI form, and a native class in separate files. I include the header file of the native class at the top of the Form.h This causes the compiler to try to compile the constructor of the Form as a native function and spits out 100+ errors and … | |
Re: You can use a stringstream, bjarne stroustrup has an example on his website under the FAQ section last I checked. Try this on for size, and it can certainly be improved with error checking, etc. [code] #include <sstream> #include <string> template<typename value_type> value_type FromString( std::string input ){ value_type r = … | |
Re: I'm not saying this is the best way to do what you want, but you can #ifndef out a block of code: [code] //#define TESTING #ifdef TESTING void Test(){ //<-- inactive pre-processor block. } #endif #ifndef TESTING void Real(){ //<-- Active code. } #endif [/code] | |
Re: scheduler, egg timer, advanced start menu, a better GUI for the windows command prompt, I would be willing to bet there is a list of project ideas on this website somewhere too. | |
Re: Hey couldn't some IPC simulate some multi-threading? I.e., spawn a few different processes as "threads". | |
Re: If you think it would help, another option would be defining the equality operator as a macro. [code] #define is_equal_to == [/code] | |
Re: MSDN says: [url]http://msdn.microsoft.com/en-us/library/ms645489(v=vs.85).aspx[/url] See under the "Initializing a Text Buffer" section here: [url]http://msdn.microsoft.com/en-us/library/bb775456(v=vs.85).aspx#text_buffer[/url] | |
Re: Well you will probably have to download the DirectX 10 SDK before you can compile much DirectX code. You also may have to set some compiler/project options. If you are patient, I'm quite sure you can discover the source of your problems. What compiler/IDE are you using? | |
Re: Try writing some pseudo-code for an algorithm. When you run into trouble with your own implementation, let us know. | |
Hello, I'm hoping you can help me make a smart decision. I have some code written in native C++, a full program actually--and I need to use it with C#. The application is, at the moment, very basic. It has a console user interface, and settings need to be changed … | |
Re: I might suggest a polymorphic solution to getting your input, I think it will greatly simplify the process of reading from stdin/cin or a file. [code] void read(std::istream &in){ //Feel free to swap width/height if needed. for(size_t i = 0; i < width; i++){ for(size_t j = 0; j < … | |
I've found that often in my code I have a need for primitive variables protected with synchronization objects such as a boost::mutex, and I was wondering if the boost library provides a template similar to this one I'm considering, based on the C# property methods get/set: [code] template<typename var_type> class … | |
Re: I can tell you GetAsyncKeyState will return true a million or so times per key press. You can check the return value for information about the keypress, it should return different values for key-down and key-up. Try this: [code] if(GetAsyncKeyState(VK_F1) == -32767) { this->checkBox1->Checked = ! this->checkBox1->Checked;//Toggle } [/code] | |
Do any of you (reading this) know of a good learning resource for implementing a neural network, instead of papers describing the theory? Or perhaps someone can explain how one can apply the information on perceptrons given [URL="http://www.cprogramming.com/tutorial/AI/perceptron.html"]here.[/URL] | |
Re: I was thinking he thought dividing by zero would throw an exception as with C# and probably other .NET languages. It doesn't. | |
Re: I think you need to print a "report header" then the values of the 4 columns on each row, one row per year. It also tells you to use a function you wrote previously. | |
What would be a common strategy for using DLLs coded in native C++ in C#? I'm not really finding much good information about it, other than writing the DLL in C. | |
Re: Is "stateB" a constant? The compiler may be whining that you are trying to initialize the array with dynamic data. | |
Re: I'm not sure if this is your problem, but with some methods of getting input, stuff will be left in the input stream, or error bits will be set. You must clear the errors and ignore newlines. Personally I prefer to sync() the stream with the source of characters. |
The End.