147 Posted Topics

Member Avatar for DubyStev

It's impossible to pass a C array by value (see why [here](http://stackoverflow.com/questions/7454990/why-cant-we-pass-arrays-to-function-by-value)). If you want a function that can handle 2x2 and 3x3 and, in general, MxN arrays, you could use a function template. #include <iostream> using namespace std; void print2x2(int array[2][2]) { for (int i = 0; i < …

Member Avatar for mike_2000_17
0
239
Member Avatar for citizen5

Don't forget to get the debug privilege before opening a process other than your own. [Useful link](http://www.daniweb.com/software-development/cpp/threads/372173/how-do-i-search-for-a-memory-address-containing-a-specific-value-). Also, don't forget to close your handles once you're done (I forgot to do it...). [Another useful link](http://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx).

Member Avatar for citizen5
0
512
Member Avatar for Stjerne

[Here](http://zetcode.com/tutorials/javaswingtutorial/swinglayoutmanagement/)'s another good link. My personal favourite is the Box Layout: import java.awt.Dimension; import java.awt.Font; import javax.swing.*; public class Main extends JFrame { void init() { // we'll use a main panel and four row-panels JPanel basicPanel = new JPanel(); basicPanel.setLayout( new BoxLayout(basicPanel, BoxLayout.Y_AXIS)); JPanel titleRow = new JPanel(); titleRow.setLayout( …

Member Avatar for Stjerne
0
167
Member Avatar for samytaqq

Oh, come on, guys, don't be so harsh. Let's help him get started... You could use two big sized arrays to represent your stacks. You'll have to also use two integers (initialized to zero) to keep track of each stack's current size. When you want to add a number to …

Member Avatar for m4ster_r0shi
0
136
Member Avatar for OldDeveloper01

What if you cast **rnd2** to an int? `ques.setText(questions[(int) rnd2]);` Note that you don't really need **Math.ceil** here. You could just do... `ques.setText(questions[(int) (Math.random() * questions.length)]);`

Member Avatar for m4ster_r0shi
0
245
Member Avatar for easterbunny

Obviously, this... for(int i = 0; i > nrEle ; i++){ for(int j = 0; j > nrEle; j++){ should be... for(int i = 0; i < nrEle ; i++){ for(int j = 0; j < nrEle; j++){

Member Avatar for easterbunny
0
863
Member Avatar for K33p3r

If you have to code this yourself, one way to do it would be to use the [inverse transformation](http://en.wikipedia.org/wiki/Inverse_transform_sampling) and [acceptance-rejection](http://en.wikipedia.org/wiki/Rejection_sampling) methods. I had to simulate normal distribution a while ago and that's how I did it: #include <iostream> #include <algorithm> #include <vector> #include <cstdlib> #include <ctime> #include <cmath> using …

Member Avatar for m4ster_r0shi
0
354
Member Avatar for phorce

>I have a vector of doubles and I need to [...] write the contents to a **text** file. What's wrong with simply opening the file in text mode, iterating through your vector and outputing each double? **main.cpp** #include <iostream> #include <fstream> #include <vector> using namespace std; int main() { vector<double> …

Member Avatar for m4ster_r0shi
0
135
Member Avatar for triumphost

> I'm not sure how I would check if the values are 'parse-able' or not You could use a stringstream for that. First, get rid of the trailing whitespace characters in your input. Then, create a stringstream out of your input and use it to set your variable's value. If …

Member Avatar for m4ster_r0shi
0
2K
Member Avatar for KrossFaith

You really should google more before posting. Look, I found a [thread](http://www.dreamincode.net/forums/topic/205131-about-bar-chart/) with a guy having the exact same code and a very similar problem to the one you're having. Considering the degree of similarity, I believe the replies he got should also be applicable to your case.

Member Avatar for m4ster_r0shi
0
289
Member Avatar for compsci91

> [...] The second should accept two arguments of type string (not C-string types) [...] Why do you use C-strings in your code then? > [...] Intuitively I would think template in C++ [...] You're right. Your maximum function template works fine for both doubles and std::strings. Also, as nullptr …

Member Avatar for m4ster_r0shi
0
156
Member Avatar for dinners

It didn't work because you did something like this: while (numbersList >> type >> num1 >> num2) // you read a line here { Complex *object = new Complex(type,num1,num2); numbersList >> type >> num1 >> num2; // and then you read another line here cout << "For line number " …

Member Avatar for m4ster_r0shi
0
98
Member Avatar for angrymasteryoda

If you want to restrict input to integers in [1, 5], your while condition should be different. One way to do it is by using two relational operators and the logical OR operator.

Member Avatar for WaltP
0
142
Member Avatar for beginneronce

What if you make your get functions return references? vector<string> & getcoursename() {return coursename;} vector<double> & getmark() {return mark;}

Member Avatar for beginneronce
0
716
Member Avatar for pattilupwned

Actually, this is one of the things the OP, surprisingly, did right. I'm saying "surprisingly" because this is a very common mistake among beginners. Assuming... [CODE]string word; ifstream file("in.txt"); // in.txt contains a list of words[/CODE] ...what most beginners do when reading that file is this: [CODE]while (!file.fail()) { file …

Member Avatar for m4ster_r0shi
0
218
Member Avatar for mikrosfoititis

Geia sou Giannakh :D Kalws hr8es sto daniweb! Einai polu wraio na vlepw atoma apo thn patrida edw :) (translation ->) Hello, John :D Welcome to daniweb! It's very nice to see people from home here :)

Member Avatar for Jashandeep
0
164
Member Avatar for subith86

I have a couple of things to say regarding the base choice. In general, you'll want your base to be as big as possible, because this implies faster operations. However, there are other factors you should also consider, such as potential overflow during operations and conversion time from and to …

Member Avatar for VernonDozier
0
2K
Member Avatar for daviddoria

Without optimizations, I get: [ICODE]0.078 seconds. 0.047 seconds.[/ICODE] With -O3 (best speed optimization) and after setting [ICODE]numberOfIterations[/ICODE] to [ICODE]1e9[/ICODE], I get: [ICODE]0 seconds. 3.297 seconds.[/ICODE] I use the version of mingw that comes along with the latest Code::Blocks.

Member Avatar for mike_2000_17
0
82
Member Avatar for Raymond10

It shouldn't be too difficult. You could either create another function to display the polynomial or add a couple of cout statements in your current function. In either case, you'll probably need two for loops, an outer one that will iterate over f(x0), f[x0, x1], ..., f[x0, ... xn] and …

Member Avatar for Raymond10
1
134
Member Avatar for daviddoria

Why do you want to specify the template parameters explicitly? I'm not really sure I understood what you want, so I'll just list a couple of things hoping one or two of them suits your needs. [CODE]#include <iostream> #include <vector> template <class T> class Simple { }; template <class T> …

Member Avatar for daviddoria
0
168
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
313
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
209
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
134
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
151
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
164
Member Avatar for kylelendo
Member Avatar for Narue
-1
229
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
215
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

The End.