147 Posted Topics

Member Avatar for ChrisMackle

Another reason might be that your program can't find SDL.dll and/or SDL_image.dll. The former comes along with SDL but the latter doesn't (AFAIK). You can get it from here -> [URL="http://www.libsdl.org/projects/SDL_image/"]SDL_image[/URL]. Copy these two dlls next to your exe and see if it works. EDIT: Hmmm... It looks like you'll …

Member Avatar for m4ster_r0shi
0
316
Member Avatar for daviddoria

Okay. In this case, an [URL="http://www.boost.org/doc/libs/1_48_0/libs/iterator/doc/indirect_iterator.html"]indirect_iterator[/URL] is exactly what you need.

Member Avatar for mike_2000_17
0
212
Member Avatar for daviddoria

Another option would be to use [URL="http://www.boost.org/doc/libs/1_48_0/libs/iterator/doc/index.html"]Boost.Iterator[/URL].

Member Avatar for ravenous
0
135
Member Avatar for Smartflight

You don't have to call [ICODE]strlen[/ICODE] or any other function to compute your word's length. Notice that, inside your loop, [ICODE]c[/ICODE] represents the number of correct consecutive letters. Just add a bool variable outside your loop and modify it appropriately inside the loop: [CODE]bool found = false; while(true) { if …

Member Avatar for Smartflight
0
15K
Member Avatar for flagstar
Member Avatar for jwenting
2
1K
Member Avatar for jayesh.rocks

[QUOTE=Narue]Show me yours and I'll show you mine.[/QUOTE] Am I the only one who keeps misinterpreting that?

Member Avatar for MonsieurPointer
-5
154
Member Avatar for Onlineshade

[QUOTE=Narue]I don't do graphics.[/QUOTE] Why not? Doing graphics can be so much fun! I do graphics all the time! :D Here's something I've been working on lately -> I saw this [URL="http://www.newgrounds.com/portal/view/578450"]flash game[/URL] where the sprite animations where created by applying a series of transformations (scalings, rotations, shearings, translations... etc) …

Member Avatar for m4ster_r0shi
0
165
Member Avatar for kylelendo
Member Avatar for Narue
-1
233
Member Avatar for fibbo

[QUOTE=fibbo]I just would like some input/critics/heads up on my class definition and implementation I did for my project.[/QUOTE] Looks good. There are a couple of small issues, but other than that looks good. About the small issues now... Your [ICODE]m_vector[/ICODE] doesn't have to be a vector pointer. A vector object …

Member Avatar for fibbo
0
218
Member Avatar for UGndLord

You can find the functions you need here -> [URL="http://msdn.microsoft.com/en-us/library/ms682073(v=vs.85).aspx"]Windows Console Functions[/URL] Here, I wrapped them for you: [CODE]#include <windows.h> #include <iostream> void gotoxy(int x, int y) { COORD pos = { x, y }; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } int wherex() { CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); return csbi.dwCursorPosition.X; } int wherey() …

Member Avatar for Narue
0
3K
Member Avatar for bubbinos

I know this is marked as solved, but I believe that the above example yields duplicate numbers, too. I think the OP is looking for a [URL="http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle"]shuffling algorithm[/URL].

Member Avatar for Adak
0
215
Member Avatar for ChaseRLewis

What's wrong with simply using the [I]address[/I] of [ICODE]m_type[/ICODE] as the unique ID you want? Here's an example -> [url]http://www.cplusplus.com/forum/general/33296/#msg179678[/url]

Member Avatar for ChaseRLewis
0
259
Member Avatar for sneekula

... you laugh with things like "Chuck Norris can dereference a void pointer." or "In Soviet Russia, functions call [B]you[/B]."

Member Avatar for Netcode
0
674
Member Avatar for sasho648

While multithreading is indeed the way to go in such cases, I believe the OP might be able to get away with just a [ICODE]_kbhit[/ICODE] call. [CODE]#include <windows.h> #include <conio.h> #include <iostream> int main() { int counter = 0; char ch = 0; while (true) { ch = 0; if …

Member Avatar for sasho648
0
313
Member Avatar for imstarting

[QUOTE=imstarting]I found a video course like that: [url]http://video-courses-online.com/programming-courses-online/c-course.php[/url][/QUOTE]Why pay for it when there are plenty free ones out there? Here's one of the few I find decent -> [URL="http://www.thenewboston.com/?cat=66&pOpen=tutorial"]decent C++ video tutorial[/URL]

Member Avatar for m4ster_r0shi
0
250
Member Avatar for TrustyTony

Ok, since nobody has replied yet, I thought I'd give it a shot. Warning -> I'm not an expert, at all. I just started learning python. The above statement prints 7, left zero padded, so that the total number of digits is 3. You can also put 3 in the …

Member Avatar for Purkinje
1
195
Member Avatar for dubez001

Yeah, I had a similar problem too when I started playing with SFML. The solution is simple, but I don't really understand how/why it works... The main problem is this here -> [ICODE]sf::Shape Rect2 = sf::Shape::Rectangle(50, 0, 70, 20, sf::Color::Blue);[/ICODE]. It should be -> [ICODE]sf::Shape Rect2 = sf::Shape::Rectangle(0, 0, 20, …

Member Avatar for dubez001
0
369
Member Avatar for nishajain

[QUOTE=Narue]C++ does not allow nested functions either.[/QUOTE] Technically, true. But there are workarounds -> [URL="http://www.respower.com/~earlye/programming/19990916.001.htm"]nesting functions in C++[/URL] However, I'm quite sure that this is not what the OP is looking for...

Member Avatar for m4ster_r0shi
-1
146
Member Avatar for mrnutty

This isn't much of a challenge as it is now, so I decided to do the interesting stuff during compilation. EDIT: A boost preprocessor array can't have more than 25 elements. That's why I had to split the letters like that. [CODE]#include <boost/preprocessor/repetition/repeat.hpp> #include <boost/preprocessor/comparison/less.hpp> #include <boost/preprocessor/arithmetic/add.hpp> #include <boost/preprocessor/arithmetic/sub.hpp> #include …

Member Avatar for iamthwee
1
151
Member Avatar for riotburn

The problem is here -> [ICODE]if(i [COLOR="Red"]=[/COLOR] rhs.size - 1)[/ICODE]. It should be -> [ICODE]if(i [COLOR="Green"]==[/COLOR] rhs.size - 1)[/ICODE]

Member Avatar for riotburn
0
118
Member Avatar for thecoolman5

Another good option is the ClipCursor function: [CODE]#include <windows.h> int main() { RECT old_rect; GetClipCursor(&old_rect); RECT new_rect = { 500, 500, 501, 501 }; ClipCursor(&new_rect); Sleep(2500); ClipCursor(&old_rect); return 0; }[/CODE]

Member Avatar for pseudorandom21
0
684
Member Avatar for milan2011

There are a couple of things that need to be fixed. (1) This is a problem -> [ICODE]p = (Translator*)malloc(sizeof(Translator));[/ICODE] because malloc doesn't call constructors. This means that the underlying string objects are not initialized properly (perhaps some internal pointers are not set?). Therefore, the program crashes when you try …

Member Avatar for m4ster_r0shi
0
682
Member Avatar for amaanbhae

And I need world peace. If you can give me that, I'll gladly give you a class of string.

Member Avatar for Ketsuekiame
-5
181
Member Avatar for Prosammer

The problem is that you never create a [ICODE]cs_EnableOverrideAction[/ICODE] object in main. What you create in main is just an uninitialized pointer that could point to anything. This will work fine -> [ICODE]cs_EnableOverrideAction * enableit = new cs_EnableOverrideAction;[/ICODE] This would also work find -> [ICODE]cs_PureFunction * enableit = new cs_EnableOverrideAction;[/ICODE] …

Member Avatar for Prosammer
0
194
Member Avatar for king03

These -> [ICODE]15 32 50 32 15[/ICODE] are the coefficients of the polynomial you'd get if you multiplied the polynomials [ICODE]3*x^2 + 4*x + 5[/ICODE] and [ICODE]5*x^2 + 4*x + 3[/ICODE] together. Useful links -> [URL="http://en.wikipedia.org/wiki/Convolution#Discrete_convolution"]Discrete Convolution[/URL], [URL="http://en.wikipedia.org/wiki/Cauchy_product"]Cauchy Product[/URL]

Member Avatar for m4ster_r0shi
0
110
Member Avatar for LevyDee

How about using virtual functions? [CODE]#include <iostream> using namespace std; struct A { virtual void print_me() const {} virtual ~A() {} }; struct B : A { void print_me() const { cout << "Hello, I'm B!" << endl; } }; struct C : A { void print_me() const { cout …

Member Avatar for LevyDee
0
120
Member Avatar for fashxfreak

It depends. If n denotes the number of rows (or columns - it's the same, since it doesn't make sense to check if a rectangular matrix is symmetric), then the above algorithm's complexity is O(n^2). But if n denotes the number of elements, then, yes, the above algorithm's complexity is …

Member Avatar for m4ster_r0shi
0
122
Member Avatar for dilequeno

Can you tell us what you want to do with the array? We may be able to suggest a better solution.

Member Avatar for Greywolf333
-1
197
Member Avatar for dilequeno

[QUOTE=dilequeno]I want to do the same thing with a 3D vector. How would the code look?[/QUOTE] You can do it like this: [CODE]vector<vector<vector<float> > > vec (5, vector<vector<float> > (5, vector<float> (5, 0) ) );[/CODE] The above creates a 5 x 5 x 5 3D vector, with all initial values …

Member Avatar for m4ster_r0shi
0
143
Member Avatar for tiredoy

Note that you have to [ICODE]#define _WIN32_WINNT 0x0500[/ICODE] [B]before[/B] including windows.h in order to be able to use GetConsoleWindow. It says so in the remarks section of the relevant link posted above.

Member Avatar for m4ster_r0shi
0
186
Member Avatar for Sonia11

And if you want to stick to the current standard, you can always use boost lambdas: [CODE]#include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> #include <algorithm> #include <iostream> #include <vector> #include <map> int main() { using namespace boost::lambda; std::vector<int> items(25); std::map<int, int> counts; for (int i = 0; i < 25; ++i) items[i] = …

Member Avatar for L7Sqr
0
4K
Member Avatar for sergent

How about something less tricky. Something like this: [CODE]#include <windows.h> #include <iostream> #include <cmath> bool IsPressed(int vkey) { return GetAsyncKeyState(vkey) >> 15; } void MouseMove(int dx, int dy) { POINT point; GetCursorPos(&point); SetCursorPos(point.x + dx, point.y + dy); } const double slope_max = 1.35; const double slope_change = 0.15; const …

Member Avatar for sergent
1
277
Member Avatar for tiredoy

I don't know what you mean by saying "hook", but if you want to hide the console cursor, you can do it like this: [CODE]#include <windows.h> #include <iostream> int main() { HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO cursor_info; GetConsoleCursorInfo(console, &cursor_info); cursor_info.bVisible = false; SetConsoleCursorInfo(console, &cursor_info); std::cout << "See? No cursor! -> …

Member Avatar for tiredoy
0
231
Member Avatar for kumarmpk4u
Member Avatar for kumarmpk4u
0
411
Member Avatar for rayden150
Member Avatar for mike_2000_17
0
256
Member Avatar for tikoti

The [ICODE]setw[/ICODE] manipulator has the same problem. It only affects the next output operation. AFAIK, there is no way you can avoid setting the width over and over again. Maybe someone else knows better though. Here's a simple hackish solution: [CODE]#include <iostream> #include <sstream> using namespace std; class ostream_w : …

Member Avatar for tikoti
0
2K
Member Avatar for spetro3387

If you want to modify something inside a function, you should pass it by reference ;) This will work -> [ICODE]void change(float (*[B]&[/B]d)[3], float (*e)[3]) { d = e; }[/ICODE]

Member Avatar for spetro3387
0
152
Member Avatar for old_kid

As pseudorandom suggested, the first step would be to convert the integer to a string. Alternatively, if you want to skip that step, you could just get a string from the user. Now, let's take a look at the algorithm... Suppose the user enters this -> [ICODE]"1234567890"[/ICODE]. The result of …

Member Avatar for m4ster_r0shi
0
144
Member Avatar for clickspiker23

I'm pretty sure the statement updating your population should be -> [ICODE]population *= (1 + annualBirth - annualDeath);[/ICODE]

Member Avatar for m4ster_r0shi
0
137
Member Avatar for thecoolman5

Check this out: [CODE]#include <iostream> #include <cmath> using namespace std; int main() { double val_1 = 1.56356; double val_2 = 1.56756; cout << floor( (val_1 + 0.005) * 100.0 ) / 100.0 << endl; cout << floor( (val_2 + 0.005) * 100.0 ) / 100.0 << endl; return 0; }[/CODE] …

Member Avatar for m4ster_r0shi
0
467
Member Avatar for Kesarion

You can use ReadProcessMemory: [CODE]#include <windows.h> #include <iostream> #include <cstring> using namespace std; int main() { char data[20] = "Hello, World!!!"; char buffer[20] = { 0 }; HANDLE my_process = GetCurrentProcess(); unsigned long address = 0; cout << "(before) " << data << endl; while (true) { ReadProcessMemory(my_process, (LPCVOID) address, …

Member Avatar for m4ster_r0shi
0
556
Member Avatar for Graphix

Are you sure the library doesn't exist in your MinGW folders? I have the latest version of Code::Blocks/MinGW and I was able to locate it here -> [ICODE]...CodeBlocks\MinGW\lib\libpsapi.a[/ICODE] See if you can find it, link to it and see if the problem persists.

Member Avatar for m4ster_r0shi
0
941
Member Avatar for ravenous

What if you try [ICODE]std::cout << [B]M_pGSLData->data[/B] + i*[B]M_pGSLData->tda[/B] + j << " ";[/ICODE] instead?

Member Avatar for ravenous
1
384
Member Avatar for Ana_Developer

[ICODE]map<uint16_t,set<float[U]>>[/U][/ICODE] <- This here means the OP uses Visual Studio ;) This should work -> [url]http://msdn.microsoft.com/en-us/library/0d462wfh(v=VS.90).aspx[/url]

Member Avatar for mike_2000_17
0
151
Member Avatar for newcoder310

What do you mean when you say "special characters"? And what do you mean when you say "space"? Try this as your pattern -> [ICODE][^A-Za-z\\s0-9][/ICODE] ( '\s' means space, tab, newline etc... ) Useful link -> [url]http://download.oracle.com/javase/tutorial/essential/regex/[/url]

Member Avatar for m4ster_r0shi
0
115
Member Avatar for Voldemort2

Try this: [CODE]//... string = string.replace('\', '/'); // replace \ with / string = string.replace('\"', ' '); // replace " with space string = string.trim(); // remove leading and trailing spaces //...[/CODE]

Member Avatar for stultuske
0
135
Member Avatar for thecoolman5

[CODE]//... if(n1 < n2) { cout << "You beat the high score of " << n1 << "." << endl; file.seekp(0, ios::beg); // move to the beginning of the file before writing file << n2 << endl; // I believe you want to write the new high score } //...[/CODE]

Member Avatar for thecoolman5
0
1K
Member Avatar for gujinni

Your program doesn't remove anything :P It just outputs the string omitting the first letter. E.g., entering this -> [B]aaabbbddccc[/B] will cause your program to output this -> [B]aabbbddccc[/B] Can you describe in english how you would remove duplicates from a string? If I give you this string -> [B]aaabbbddccc#[/B] …

Member Avatar for gujinni
0
190
Member Avatar for mchin131

Two things you need to do: (1) Read the data from the file (put [ICODE]widgets >> d_...[/ICODE] statements first thing inside your for loop). (2) Print the data only after you get all of it (close your for loop immediately after closing [ICODE]if(!head)[/ICODE]).

Member Avatar for m4ster_r0shi
0
207
Member Avatar for gauravk_bhanot

[QUOTE=gauravk_bhanot]when the base pointer points to derived object it prints i am derived[/QUOTE] This is exactly what it's supposed to do. Take a look at this: [CODE]#include <iostream> #include <vector> using namespace std; struct Fruit { virtual void Speak() {} virtual ~Fruit() {} }; struct Apple : Fruit { void …

Member Avatar for gauravk_bhanot
0
207

The End.