Posts
 
Reputation
Joined
Last Seen
Ranked #232
Strength to Increase Rep
+9
Strength to Decrease Rep
-2
96% Quality Score
Upvotes Received
59
Posts with Upvotes
49
Upvoting Members
48
Downvotes Received
2
Posts with Downvotes
2
Downvoting Members
2
23 Commented Posts
3 Endorsements
Ranked #486
Ranked #383
~112.54K People Reached
About Me

I am the lord of the wind.

Favorite Tags

147 Posted Topics

Member Avatar for rfrapp

Are you familiar with functions? If not, it's a good time to start learning about them. As pointed out by others above, breaking the task into smaller steps helps a lot. So, let's focus on building a line first. Take a look at these lines: 122222221 123333321 123444321 There is …

Member Avatar for pty
0
1K
Member Avatar for nitin1

> Less overhead Not really. I don't know what compiler you're using, but any decent one would seize the opportunity to perform [tail call optimization](http://en.wikipedia.org/wiki/Tail_call) in np complete's code, and generate output **identical** to the one corresponding to an iterative implementation. > easier to read I think this is the …

Member Avatar for ShapesInClouds
0
3K
Member Avatar for Riteman

You can always use the C version of ostringstream -> [url]http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/[/url]

Member Avatar for angham kh
0
4K
Member Avatar for Dani

Careful! The relevant threads in the Software Development and Web Development forum categories are not sticky! Or at least that's what I see... ![not_sticky](/attachments/large/2/not_sticky.PNG "not_sticky")

Member Avatar for L7Sqr
3
1K
Member Avatar for Bumpehh

>I fixed it. i downloaded the dll from a website and added it to my bin folder. Downloading dlls from random sites is not a very wise thing to do. You never know what kind of code these dlls may contain. I'm talking about security issues. Your pc could as …

Member Avatar for m4ster_r0shi
0
158
Member Avatar for samohtvii

> Ok so what i was thinking was add the nodes in sequence. so the text file would be Does it have 4 legs? Does it purr? Cat Dog Does it swim? fish What you do here is called printing the tree using [preorder traversal](http://en.wikipedia.org/wiki/Tree_traversal#Depth-first_traversal). > Does this **require** recursive …

Member Avatar for samohtvii
0
3K
Member Avatar for breezeonhold

> There are no tests what-so-ever in your code. Yes, there are. They are inside the [strncpy](http://www.cplusplus.com/reference/clibrary/cstring/strncpy/) and [strncat](http://www.cplusplus.com/reference/clibrary/cstring/strncat/) functions. > I've had some people say to do result_maxlength-1 They are right. In your first `concat` call, this -> `result[result_maxlength] = '\0';` turns to -> `c[5] = '\0';`. You're going …

Member Avatar for m4ster_r0shi
0
143
Member Avatar for Jsplinter

I have a couple of questions: What happens if you increase the number of calculations you have to make per iteration? Are you sure you're timing the hardcoded approach properly? What optimization flags are you using? Check this out: #include <windows.h> #include <iostream> #include <algorithm> #include <vector> using namespace std; …

Member Avatar for Jsplinter
0
269
Member Avatar for Despairy

> I was thinking about somehow using a static member that all the matrix cells will be defined by their value + the static value. This is a very interesting idea. It also is easily generalized. You could have a stack of (different) operations and apply them in order when …

Member Avatar for Despairy
0
299
Member Avatar for soapy.thomas

cin is fine too. What you need to do is clear your stringstream's buffer and state before you use it again. Either add this here -> `ss.str(""); ss.clear();` before using ss or create ss right before you use it. Also, the condition in your if statement should be `!ss || …

Member Avatar for m4ster_r0shi
0
400
Member Avatar for Bumpehh

Now, let's add some [basic AI](http://ideone.com/2ND3o). Nothing too serious, just a simple, suboptimal (you could use the [KMP algorithm](http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm) to improve it), history matcher. It searches the user's previous moves for recurring patterns and uses this information to predict the user's next move. For anyone interested in more advanced stuff, …

Member Avatar for m4ster_r0shi
0
1K
Member Avatar for im abcd

> `num = ((-b) + sqrt(b*b-4*a*c))` > `den = (2*a)` It's unlikely that `sqrt(b*b-4*a*c)` will be an integer (or even a rational number). A better approach would be something like this: ... p = -b q = b*b-4*a*c r = 2*a ... print "x = (" print p print " …

Member Avatar for im abcd
0
424
Member Avatar for aabbccbryanmark

[Looks](http://ideone.com/9pjS4) like [Perl](http://www.perl.org/) to me.

Member Avatar for WaltP
0
301
Member Avatar for <HHH>

Or better yet, vectors, since the number of lines in the file is not known during compilation. #include <iostream> #include <fstream> #include <vector> #include <string> using namespace std; int main() { ifstream fin("main.cpp"); vector<string> lines; string curLine; while (getline(fin, curLine)) lines.push_back(curLine); for (size_t i = 0, size = lines.size(); i …

Member Avatar for m4ster_r0shi
0
134
Member Avatar for sozan.galal

>I wonder which is better :to start learning a new programming language or develop my skills in the C++ language ? Both have advantages. What you should do depends on several things. One of these things is what is it that makes you face this dilemma. Do you have some …

Member Avatar for m4ster_r0shi
0
172
Member Avatar for userIT

There is a problem with the logic you use to generate the random indexes. Let's start with something simpler. Suppose you want to get three unique random values from a unidimensional array of four elements. The easiest way to do this is by using [random_shuffle](http://www.cplusplus.com/reference/algorithm/random_shuffle/): #include <iostream> #include <string> #include …

Member Avatar for userIT
0
537
Member Avatar for Bumpehh

>im thinking of a game in the Command Prompt Read [this](http://www.cplusplus.com/forum/articles/28558/) first. IMO, the thing with the best result-to-effort ratio you can do right now is grabbing a graphics library (e.g. [SFML](http://www.sfml-dev.org/)) and writing a simple [scrolling shooter](http://en.wikipedia.org/wiki/Shoot_'em_up#Types). And if you 're worrying about your artistic skills, don't. Computer software …

Member Avatar for Bumpehh
0
737
Member Avatar for sillyboy
Member Avatar for Helianthus
0
5K
Member Avatar for triumphost

Here's an idea: #include <iostream> #include <string> template <class A, class B> struct SameType { static const bool Result = false; }; template <class A> struct SameType <A, A> { static const bool Result = true; }; template <bool C, class True, class False> struct IfThenElse; template <class True, class …

Member Avatar for Schol-R-LEA
0
842
Member Avatar for schlulol

> I've tried to do some research on this minimax thing, but I couldn't find anything helpful. How much did you search? I just googled **connect four c++ minimax** and I found this [video](http://www.youtube.com/watch?v=kHJRdHCSQLE) on youtube. In the description of that video, I found this [link](http://users.softlab.ece.ntua.gr/~ttsiod/score4.html), There, you can see …

Member Avatar for m4ster_r0shi
0
316
Member Avatar for Dudearoo

Judging by the way you use getline, `teamnamesquestion` must be a char array. The problem with this is that `teamnamesquestion == "no"` performs a pointer equality check, that will, obviously, always return false. If you don't believe me, try this: #include <iostream> using namespace std; int main() { char str[10]; …

Member Avatar for rubberman
0
160
Member Avatar for poloblue

> You are missing endl or flush at the end of most of your output statements. This is a joke, right? It has to be a joke, because neither is it true nor does it have anything to do with the OP's problem. The OP's problem arises from mixing istream::operator …

Member Avatar for m4ster_r0shi
-1
140
Member Avatar for Taniya19

So, what you essentially want is **efficient calculation of [multinomial coefficients](http://en.wikipedia.org/wiki/Multinomial_theorem#Multinomial_coefficients)**. I googled that, and the first link I got was [this](http://home.comcast.net/~tamivox/dave/multinomial/index.html).

Member Avatar for TrustyTony
0
168
Member Avatar for Albino

> not all control paths return a value This means that you have code that looks like this: ReturnType load_image(ArgType1 arg1, ArgType2 arg2, ...) { //... if (some_condition) return something; // What happens if some_condition is false? // You don't return anything in that case... } > The first two …

Member Avatar for Albino
0
470
Member Avatar for gali01

@OP: [Moschops](http://cplusplus.com/forum/beginner/72307/#msg385772) is right. I fixed these errors, compiled the code you posted and got the [expected output](http://zifda.wordpress.com/2011/12/16/morphing-pada-opengl/#more-331).

Member Avatar for m4ster_r0shi
0
104
Member Avatar for Dasttann777

> If you are writing a simple program that resembles a language interpreter, and it is capable of computing non-trivial equations of more than a fixed size, then you really are talking about writing an intepreter. You'll want to go the whole route of tokenizing and parsing the input, even …

Member Avatar for m4ster_r0shi
0
169
Member Avatar for OrangeTree

If you have to do it using sscanf, you could do it like this: #include <iostream> #include <cstdio> using namespace std; int main() { string path = "main/articles/animals/giraffe"; char * cPath1 = new char[path.size()]; char * cPath2 = new char[path.size()]; sscanf(path.c_str(), "%[^'/']/%[]", cPath1, cPath2); string path1(cPath1), path2(cPath2); delete[] cPath1; delete[] …

Member Avatar for OrangeTree
0
245
Member Avatar for SandraD

I think you may be using the wrong language for this. It's certainly doable, but there are much better alternatives (at least on windows). One such alternative is [Autoit](http://www.autoitscript.com/site/autoit/). Here's an example that does what you want with notepad: $file = FileOpen("C:/in.txt") $line2 = FileReadLine($file, 2) Run("notepad.exe") WinWait("[CLASS:Notepad]") ControlSend("[CLASS:Notepad]", "", …

Member Avatar for WaltP
0
112
Member Avatar for Dasttann777

You don't really need to understand how std::map works in order to understand how to use it. I have an idea. Let's ask the OP which version (s)he finds easier to implement / understand. This one -> http://ideone.com/ojv1H ? Or this one -> http://ideone.com/Vz9oh ?

Member Avatar for m4ster_r0shi
0
161
Member Avatar for SalicBlu3

> Why not just create array as a large array? Say int array[1000]? While this would work if this is just homework, it's not a good idea in general, as it creates a huge security hole in the application. [Here](http://stackoverflow.com/questions/2039953/frame-pointer-program-counter-array-overflow)'s an interesting thread I found regarding that matter. > The …

Member Avatar for m4ster_r0shi
0
133
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
241
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
514
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
171
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
139
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
246
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
359
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
136
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
292
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
160
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
100
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
144
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
717
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
223
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
84
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
137
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
171

The End.