2,712 Posted Topics
Re: >> 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. | |
Re: Did you step through the debugger? Whats your update code looking like? | |
Re: 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 … | |
![]() | Re: Replace all char arrays with, std::string, and replace all cin.getline with, [i]getline(cin,stringVariable);[/i] |
Re: 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] | |
Re: 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; … | |
Re: 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 … | |
Re: umm....[URL="http://codepad.org/"]this maybe?[/URL] | |
Re: 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] | |
Re: [B]except that using vectors is much more efficient because the dimensions are not hard coded[/B] Citation please? | |
Re: 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] | |
Re: Or just this : [code] string str[5] = {"hello","ramble","people","kitty","rope"}; vector<string> vec(str,str+5); [/code] | |
Re: 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 … | |
[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 … ![]() | |
Re: 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 … | |
Re: 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. | |
Re: 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. | |
Re: 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; … | |
Re: [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 … | |
Re: 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 … | |
Re: Because the compiler see's it as : [code] int triangle(int); [/code] | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: umm.... [code] #include <iostream> #include <string> using namespace std; int main(){ string str = "@#@#@"; cout << str << endl; } [/code] That will be $50 please. | |
Re: 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) … | |
![]() | Re: >>I believe that using a new two-dimensional array is the way to go, Why do you think so? |
Re: If you use a class or struct, did you forget to put a [COLOR="Red"];[/COLOR] at the end of the class/struct declaration? | |
Re: >>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? | |
Re: >>You have to use ofstream, not just fstream fstream inherits from ifstream and ofstream, so it can do both, read and write. | |
Re: [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] … | |
Re: 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 … | |
Re: You need to break things into functions so its more readable. Also try this : [code] while (arquivo && getline(arquivo, arquivo_linha)) [/code] | |
Re: 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] << … | |
Re: >>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 … | |
Re: [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 … | |
Re: Nice post. Although I would have done some things different, the idea is good. | |
Re: 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(). | |
Re: 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 … | |
Re: 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 … | |
Re: 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 = … | |
Re: Why not just do it manually? It'l take less time than that way. | |
Re: Here are some problems, [URL="http://www.daniweb.com/forums/thread67837.html"]link[/URL] | |
Re: 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] | |
Re: 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] | |
Re: [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 … | |
Re: [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 … |
The End.