560 Posted Topics

Member Avatar for ghost_from_sa

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]

Member Avatar for ghost_from_sa
0
191
Member Avatar for pseudorandom21

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?

0
82
Member Avatar for klangston92

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 …

Member Avatar for pseudorandom21
0
164
Member Avatar for papaSmurph
Member Avatar for vincezed

[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.

Member Avatar for vincezed
0
127
Member Avatar for lexusdominus

"::" is the scope resolution operator. namespace::class is the form of std::string.

Member Avatar for lexusdominus
0
126
Member Avatar for miguelsan

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 …

Member Avatar for miguelsan
0
92
Member Avatar for cppjosh
Member Avatar for Akill10
0
365
Member Avatar for sciprog1

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 …

Member Avatar for sciprog1
0
148
Member Avatar for Xcelled194

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 …

Member Avatar for BitBlt
0
201
Member Avatar for anish99virgo

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 …

Member Avatar for anish99virgo
0
196
Member Avatar for Khoanyneosr

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 …

Member Avatar for pseudorandom21
0
362
Member Avatar for eskimo456

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 …

Member Avatar for eskimo456
0
404
Member Avatar for pepperhead11

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 …

Member Avatar for WaltP
0
1K
Member Avatar for lxXTaCoXxl

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 …

Member Avatar for jh00
0
134
Member Avatar for cppjosh

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 …

Member Avatar for pseudorandom21
0
120
Member Avatar for SillySpAz

[i]function definition[/i] [code] void DoSomething(){ //something }[/code] [i]Function call[/i] [code] DoSomething(); [/code]

Member Avatar for SillySpAz
0
129
Member Avatar for Mr. K

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 + …

Member Avatar for pseudorandom21
-2
249
Member Avatar for Usmaan

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 …

Member Avatar for Usmaan
0
391
Member Avatar for Mr. K

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]

Member Avatar for Mr. K
0
193
Member Avatar for pseudorandom21

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 …

Member Avatar for pseudorandom21
0
95
Member Avatar for pravej

[code] #include <string> #include <algorithm> int main(){ std::string text = "reversi mei!"; std::reverse(text.begin(), text.end()); } [/code]

Member Avatar for template<>
0
246
Member Avatar for terexberd

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]

Member Avatar for pseudorandom21
0
136
Member Avatar for saya_makan37

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 …

Member Avatar for pseudorandom21
0
223
Member Avatar for Stogie2

Hey those variable names don't look very descriptive, sometimes a meaningful name is helpful.

Member Avatar for Stogie2
0
215
Member Avatar for rannamaa
Member Avatar for owenransen

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]

Member Avatar for mike_2000_17
0
165
Member Avatar for hawita

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 …

Member Avatar for pseudorandom21
0
99
Member Avatar for sergent

[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]

Member Avatar for mrnutty
0
210
Member Avatar for Japracool

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.

Member Avatar for Japracool
0
289
Member Avatar for shyla

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 …

Member Avatar for pseudorandom21
0
184
Member Avatar for pseudorandom21

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 …

Member Avatar for jonsca
0
127
Member Avatar for lochnessmonster

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 = …

Member Avatar for Caligulaminus
0
105
Member Avatar for daviddoria

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]

Member Avatar for daviddoria
0
135
Member Avatar for sha11e

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.

Member Avatar for floatingDivs
0
104
Member Avatar for DestinyChanger

Hey couldn't some IPC simulate some multi-threading? I.e., spawn a few different processes as "threads".

Member Avatar for DestinyChanger
0
212
Member Avatar for salty11

If you think it would help, another option would be defining the equality operator as a macro. [code] #define is_equal_to == [/code]

Member Avatar for salty11
0
180
Member Avatar for darkbreaker

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]

Member Avatar for darkbreaker
0
275
Member Avatar for Khoanyneosr

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?

Member Avatar for Khoanyneosr
0
157
Member Avatar for cblue

Try writing some pseudo-code for an algorithm. When you run into trouble with your own implementation, let us know.

Member Avatar for pseudorandom21
0
216
Member Avatar for pseudorandom21

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 …

Member Avatar for George Truesdel
0
788
Member Avatar for lalala423

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 < …

Member Avatar for pseudorandom21
0
165
Member Avatar for pseudorandom21

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 …

Member Avatar for vijayan121
0
259
Member Avatar for Danny1994

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]

Member Avatar for pseudorandom21
0
112
Member Avatar for pseudorandom21

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]

Member Avatar for jonsca
0
82
Member Avatar for cogitoergosum18

I was thinking he thought dividing by zero would throw an exception as with C# and probably other .NET languages. It doesn't.

Member Avatar for pseudorandom21
0
242
Member Avatar for rbduck09

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.

Member Avatar for WaltP
0
141
Member Avatar for pseudorandom21

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.

Member Avatar for mike_2000_17
0
778
Member Avatar for YodaMerlin

Is "stateB" a constant? The compiler may be whining that you are trying to initialize the array with dynamic data.

Member Avatar for YodaMerlin
0
239
Member Avatar for valestrom

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.

Member Avatar for valestrom
0
301

The End.