2,712 Posted Topics

Member Avatar for cwarn23

>> If you vote yes then animals should have the same rights as humans As a result of the survival of the fittest, its impossible for animals to have the same rights as humans, unless we don't wan't to survive or commit some fallacy.

Member Avatar for GrimJack
1
453
Member Avatar for tomtetlaw
Member Avatar for tomtetlaw
0
130
Member Avatar for dumb-one

Wow, that code is pretty bad. I don't know why you aren't using arrays for the months. Dont know why you are using inheritance when its obvious that composition is best. I'm sorry, but you need to learn the basics a lot more, before you move onto classes, inheritance and …

Member Avatar for dumb-one
0
352
Member Avatar for youllbelost

Replace all char arrays with, std::string, and replace all cin.getline with, [i]getline(cin,stringVariable);[/i]

Member Avatar for p@rse
0
122
Member Avatar for urchinsub

OMG, just use vectors : [code] #include <string> #include <vector> #include <iostream> using namespace std; class StringArray{ private: std::vector<string> strArray; public: StringArray(const std::vector<string>& vecStr): strArray(vecStr){}; void print(){ /* print vector here */; }; int main(){ std::vector<string> vec(5,"hello"); //contains 5 of "hello" StringArray strArray(vec); vec.print(); } [/code]

Member Avatar for urchinsub
0
276
Member Avatar for hotness

Here are my guess: [code] 1) Dont get the question, what does "name" mean? DataType? 2) false; 3) C: Increment operators 4) confusing 5) false; 6) c: * 7) false: runtime variable? 8) false; 9) b: 12,81 10) d: shallow 11) true; 12) false, it can; 13) false; 14) true; …

Member Avatar for mrnutty
0
2K
Member Avatar for empror9

Given two numbers, you can use std::max(a,b) to return the largest out of a and b. Thus using the same logic you can just nest std::max for 3 inputs, so std::max( std::max(a,b) , c) returns the largest out of the 3 inputs. There is a very similar patterns for 4 …

Member Avatar for hsh44
0
183
Member Avatar for insanely_sane
Member Avatar for bgreer5050

or use the library and worry about only one : [code] #include <cctype> //.. int main(){ //... do{ }while( tolower(con) != 'n'); //similarly you can do "while( toupper(con) != 'N'); } [/code]

Member Avatar for mrnutty
0
37
Member Avatar for Andreas5

[B]except that using vectors is much more efficient because the dimensions are not hard coded[/B] Citation please?

Member Avatar for Ancient Dragon
0
143
Member Avatar for Metalteeth9

umm...couple of ways, first is the easiest. [code] //option #1 string path = "AMBER/data/runx/amhsk_run"; string runNumber; cin >> runNumber; validate(runNumber); path += runNumber + ".root"; [/code] [code] //option # 2 string path = "AMBER/data/runx/amhsk_run*.root"; string runNumber; cin >> runNumber; path.replace( path.find('*'),1,runNumber) ; [/code]

Member Avatar for jonsca
0
162
Member Avatar for bubacke

Or just this : [code] string str[5] = {"hello","ramble","people","kitty","rope"}; vector<string> vec(str,str+5); [/code]

Member Avatar for bubacke
0
193
Member Avatar for uhmyeah

What exactly do you mean? If you have an object moving, and you want gravity to account for its movement, then you can just do this : [code] const float GRAVITY = -9.8; ball.x += ball.velocity.x * dt; ball.y += ball.velocity.y + GRAVITY * dt; [/code] Those follow from basic …

Member Avatar for nbaztec
0
168
Member Avatar for jrw89
Member Avatar for mrnutty

[URL="http://www.youtube.com/watch?v=WIlkX87FolQ"]This[/URL] my friend is what true love is. I feel the need to share you a story, a wonderful story. Yesterday night, I pondered about heaven and how I couldn't wait for the eternal happiness. I prayed and talked to god. Today I received a message. I felt such a …

Member Avatar for diafol
1
114
Member Avatar for arthurav

Why would you do this recursively? It will be better to do it iteratively. For example : [code] //assume coefficient is written from highest degree to lowest float evaluate(std::vector<float>& coeff, const float x){ int degree = coeff.size(); float result = 0.0f; for(int i = 0; i != degree; ++i){ float …

Member Avatar for arthurav
0
3K
Member Avatar for daviddoria

Hey how about you add some random snippet section in that wiki? So we can post random snippet there, that is unless you want to organize the wiki in some way that you would like to.

Member Avatar for Bench
4
151
Member Avatar for NathanOliver

First make use of const. Second in your NumberToString function, what happens when the conversion fails? When the stringstream cannot convert the object passed in? Handle those extreme cases as well. Also in your ContainerToString function, you could just as well use a forward Iterator and it would work.

Member Avatar for Bench
0
127
Member Avatar for altXerror

Seems like at your level, you don't need to worry about header files, because it will only complicate things for you. Just stick with 1 file for now, the main file. And by the way all of this is valid : [code] int a; int aa; int aaa; int b; …

Member Avatar for mrnutty
0
159
Member Avatar for bklearner

[QUOTE=daviddoria;1258012]I haven't compiled myself, but this is very confusing: [code] typedef struct node{ int data; struct node *next; struct node *previous; }mynode; mynode *head,*temp,*current,*tail; [/code] First, why have you used a typedef? Second, you seem to have declared an object named mynode, then tried to declare things (head,temp,etc) of type …

Member Avatar for Taywin
0
148
Member Avatar for dhruv_arora

All of these foolish replies. The guy is asking for help and you guys are messing around. So let me say this, let it be natural, don't be awkward, be confident especially, since girls don't like wimps, and start a conversation. Since you are new in the class, ask her …

Member Avatar for dhruv_arora
-1
134
Member Avatar for FudgeCoder
Member Avatar for Taywin
0
156
Member Avatar for YasaminKh

you have the starting position and the length of the string, so just start reading character by character from the starting position length number of times.

Member Avatar for YasaminKh
0
127
Member Avatar for KAY111

you know, this post seems suspicious. It looks like( at lest to me) that you are trying to get someone else's code, who wrote it a while back, to compile so you can use it either for h.w or for some school related stuff? If you don't get what graphs …

Member Avatar for KAY111
0
15K
Member Avatar for Nicco

Simpler version of your problem: [code] #include <iostream> int main(){ using namespace std; int a = 0; string str; cin >> a; getline(cin,str); //skipped?? } [/code] the problem is when you use cin to read in a number, there is a newline that gets stuck in the buffer, because cin …

Member Avatar for Nicco
0
106
Member Avatar for geethanjaliprat
Re: c++

umm.... [code] #include <iostream> #include <string> using namespace std; int main(){ string str = "@#@#@"; cout << str << endl; } [/code] That will be $50 please.

Member Avatar for LevyDee
0
71
Member Avatar for bigidiot

Is there a total amount she made? There is only 4 prices listed for 5 items, and the requirement says that every profit was a unique amount. Anyways, here is my guess, can you tell me if its correct or not. 1) popcorn[$25] 2) candybars[$60] 3) lollipops[$75] 4) fudge[$45] 5) …

Member Avatar for mrnutty
2
125
Member Avatar for Griff0527

>>I believe that using a new two-dimensional array is the way to go, Why do you think so?

Member Avatar for NathanOliver
0
1K
Member Avatar for tkud

If you use a class or struct, did you forget to put a [COLOR="Red"];[/COLOR] at the end of the class/struct declaration?

Member Avatar for tkud
0
90
Member Avatar for gomezfx

>>operator + (const money rhs) const I guess no one else saw this, but you need to specify the return type for any function. What should the return type of operator+ should be, in other words, what should the addition operation return for this class?

Member Avatar for nbaztec
0
91
Member Avatar for strwbry.coder

>>You have to use ofstream, not just fstream fstream inherits from ifstream and ofstream, so it can do both, read and write.

Member Avatar for mrnutty
0
202
Member Avatar for YasaminKh

[QUOTE=YasaminKh;1255694]hi Everyone, I'm working with a Text file. Somewhere in my code a function returns the current position of the file pointer. But i want it to go to the next line or 2 lines after to do a string search there. Anybody knows how i can do that? Bests,[/QUOTE] …

Member Avatar for mrnutty
0
112
Member Avatar for tiger86
Member Avatar for bachan28

Right now forget about creating games. Its over your head, unless you want to use something like gamemaker or something similar. First learn how to program. Pick a language, whether it be C++ , python, C# or whatever. After you get a decent amount of experience in programming, then you …

Member Avatar for bachan28
0
143
Member Avatar for fernandofranca

You need to break things into functions so its more readable. Also try this : [code] while (arquivo && getline(arquivo, arquivo_linha)) [/code]

Member Avatar for fernandofranca
0
923
Member Avatar for MaestroS

In C++ use getline : [code] #include <string> #include <vector> #include <sstream> #include <iostream> using namespace std; std::vector<string> explode(const string& text, char delim){ std::vector<string> res; string temp; stringstream ss(text); while(ss && getline(ss,temp,delim) ) res.push_back(temp); return res; } int main(){ std::vector<string> vec; vec = explode("hello world",' '); cout << vec[0] << …

Member Avatar for Stefano Mtangoo
0
887
Member Avatar for avarionist

>>how would i go about obtaining a single char from a string Huh, I'm confused on what you want, you do know you can use string.operator[] to access the individual characters right? [code] string str = "text"; char ch = str[0]; //ch equals 't' char ch2 = str[ str.size()-1]; //ch2 …

Member Avatar for NathanOliver
0
376
Member Avatar for abhi74k
Member Avatar for akssps011

[QUOTE=akssps011;1251623]In screen coordinate system i.e top left corner = (0,0) and bottom right corner = (800,600), How can we find the equation of a line given ? Also how the intersection point of this line can be calculated with the screen boundary ?[/QUOTE] Do you actually put image using the …

Member Avatar for akssps011
0
88
Member Avatar for NathanOliver

Nice post. Although I would have done some things different, the idea is good.

Member Avatar for NathanOliver
3
330
Member Avatar for dansnyderECE

First, FDT_filename[0] is not valid because there is nothing inside the vector. But to fix your error, use FDT_filename[0].c_str().

Member Avatar for dansnyderECE
0
184
Member Avatar for AspiringCoder

Here are some hints to get you started : 1) Given a number n, n mod 10, always results in the last digit of n. For example : [code] //mod = % 12345 % 10 equals 5 101011 % 10 equals 1 9234 % 10 equals 4 1 % 10 …

Member Avatar for AspiringCoder
0
187
Member Avatar for nyarufuka

Ok go ahead and get started. Just do it! That way you will learn more. And when we will help you if you have any problems, you will understand the solution better. We're not saying this because we are pricks( I speak for myself ), but give it a go …

Member Avatar for mrnutty
0
90
Member Avatar for nbaztec

First, you need to learn how to read in bitmap images. Find a tutorial with that. Then when you know how to read in a bitmap image. You should have an array of int values, which represents the color of the pixels in the images. For example : black = …

Member Avatar for nbaztec
0
351
Member Avatar for VBNick
Member Avatar for spinning_turtle
Member Avatar for mrnutty
0
49
Member Avatar for BLKelsey

Do something like this : [code] enum MenuStatus{ PLAY , EXIT }; //add more stuff here if needed MenuStatus mainMenu(){ /* menu code goes here */ } int main(){ while(mainMenu() != EXIT) continue; else { exitApp(); } } [/code]

Member Avatar for mrnutty
0
131
Member Avatar for j-green.10

here is some psuedo code: [code] declare var; start Do Loop get input into var if var is not equal to 0 then do stuff else just break out of the lop end Do Loop if var equals 0; [/code]

Member Avatar for jerry emmy
0
87
Member Avatar for riu

[QUOTE=riu;1246906]a program in c++ which take some string from user and generate a unique code against it[/QUOTE] Thats called hashing. You could do something like this : [code] string str = "abc"; unsigned long long hashCode = str[0]*1 + str[1]*2 + str[2]*3; [/code] Basically, you are multiplying the value at …

Member Avatar for oz_engineer
0
230
Member Avatar for dj_saxy

[QUOTE]Is is possible to take an array full of characters and then make the characters into numbers ?[/QUOTE] To convert from 1 char to an int just subtract '0' from it. For example : [code] char ch = '1'; int i = ch - '0'; //i = int(1); [/code] So …

Member Avatar for mrnutty
0
236

The End.