Posts
 
Reputation
Joined
Last Seen
Ranked #232
Strength to Increase Rep
+8
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
~110.41K People Reached
About Me

I am the lord of the wind.

Favorite Tags
c++ x 247
c x 17
text x 13
dev x 10
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
2K
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
153
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
141
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
266
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
294
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
397
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
405
Member Avatar for aabbccbryanmark

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

Member Avatar for WaltP
0
298
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
128
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
167
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
528
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
712
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
830
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
311
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
156
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
138
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
165
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
461
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
101
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
162
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
241
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
110
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
160
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
124