2,712 Posted Topics
Re: In my internship, they use the scrum method. It seems to be a good method. Google that. | |
Re: Why the pointer in the first place? You could manage without it, can't you? | |
| |
Re: You can delete line 158 and 193. Also quoted strings i.e [icode] "quotedStrings" [/icode] are automatically null terminated via compiler, so you don't have to manually add null character like you did here [icode]"-c\0"[/icode] | |
Re: You need to remove the redundant code and use a function: [code] int getInt(){ int input = 0; while( !(cin >> input) ){ cout << "\nPlease enter a valid input: "; cin.clear(); while(cin.get() != '\n'); } return input; } int main(){ int x = getInt() , y = getInt(), z … | |
Re: In your peek check if size() == 0 instead. And for dequeAll just deque until size == 0 | |
Re: Click on the file, hit "Ctrl + C" and goto the location where you want to paste it and hit "Ctrl + V" where the '+' means together or in conjunction. | |
Hypothetically speaking, supposed Mr.X was able to get into a restricted link in daniweb where Mr.X didn't have the privilege to do so regularly. What would happen to Mr.X is he was caught? Is there any laws against it? | |
Re: >>it cracks the string h3ar7 in 16 seconds on my computer. Thats pretty slow. There is no reason to use recursion here. | |
Re: >>[B]error: ‘template<class _Tp, class _Alloc> class std::vector’ used without template parameters[/B] This error tells you your problem. You are using std::vector without templates. Why are you confused? | |
Re: Make the member function a actual function. If more than one class actually needs it, then its nor correct to make it a member function for one class. | |
Re: [QUOTE=NathanOliver;1591717]You should be returning by reference not by value [code=c++] std::string & access(int row, int column); csv_File & grab(int index); [/code][/QUOTE] And also provide a const reference version | |
Feel free to ignore this rant. I am up to my neck with programming, so much so that I'm getting sick of it. I know I can't believe I would ever say that either. I'm at work right now( internship ), and I just want to leave. I don't want … | |
Re: [QUOTE=learningcpp;1591459]Thanks for the reply. What if I want to avoid this, lets say I have to create 10 millions of this object (10 million is too much?, mmm lets say I have unlimited memory?) then this padding will cost me 30 million of extra byte. I have tried the rearranging … | |
Time to time I see some common mistakes or even make some my self. I figure I would post some of these, with hopes that people will learn from my and others mistakes. [B]1) Why you no work?[/B] [code] int sum = 0; for(int i = 1; i < MAX; … | |
Re: Why don't you give it a try. If your stuck on something post it. We can surely do this for you, but then when time comes for you to work on your own, then your gonna have a heck of a hard time. So start early and start now. So … | |
Re: You might consider sorting then evaluating it. | |
Re: Note you should expose your vector like that instead return it by const-reference and if you need to update it, then provide proper interface. Also typedefs also might come in handy, as it is more clearer. [code] typedef std::vector<MySurvey::SurveyQuestion> Questions; //... const Questions& getSurveyQuestions()const{ return questions; } [/code] | |
Re: Look into [URL="http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=opengl"]opengl[/URL] | |
Re: [QUOTE=Ancient Dragon;1588290]When you get a first entry-level programming job you will most likely not be writing all new code yourself, but instead you will be modifying and debugging existing code (program maintenance). The only new code you might write is to make product enhancements to existing products. No one is … | |
Re: Sorting and binary search will take nlogn + logn time. Instead you can simply run through the list and spit out anyone that satisfies the requirement-- this takes linear time. | |
Re: [QUOTE=Jsplinter;1588388]How do I invoke the int operator < instead of the int* operator < ? [CODE] vector<int*> pVec; std::sort(pVec.begin(),pVec.end(), /*????*/); [/CODE][/QUOTE] Why do you need to store [i]int*[/i] anyways? Either store it as [I]vector<int>[/I] or [I]vector< vector<int> >[/I] | |
Re: I suggest Microsoft Visual Studio or eclipse or netbeans. | |
Re: >>[B]Random ;*randSelection;[/B] what do you think this means? I assume you want [icode]int randomSelection [/icode]. And add a semicolon after '}' in line 62 | |
Re: Use a if statement and a state variable. [code] int main(){ bool shouldContinue = true; do{ /***code here***/ //ask user if he want to continue char input; cout << "Continue(y/n) : " ; cin >> input; if(input != 'y') shouldContinue = false; }while(shouldContinue); } [/code] | |
Re: [QUOTE=invisal;1578241]I don't see anywhere stated that [icode]int main(int argc, char* argv[])[/icode] is better than [icode]int main()[/icode]. I wonder whether [icode]char main()[/icode] is acceptable?[/QUOTE] Quoted from wiki-god [quote] C and C++ In C and C++, the function prototype of the main function looks like one of the following: int main(void) int … | |
![]() | Re: I always workout and play basketball. Right now, my goal is to get my body fat percentage under 10%. I need the extra edge for basketball. But I recently started eating salad and chicken for dinner, to avoid carbs as much as I can at night time. |
Re: Just one more things, for question 2, its not a char type, its a array to chars, which is why in the above post, you see an array of chars | |
Re: [QUOTE=Schoil-R-LEA;1584863]As the problem instructions say, you need to have the second loop nested inside the first loop. in this case, all you really need do is remove the two cout lines between the loops, and move the endl off of the the inner loop's output, and you should be good … | |
Re: Don't initialize the variables in the header file. Initialize them in the .cpp file. In the header file, just declare them. Alternately you can do this: [code] //foo.h struct Constants{ static const float PI; static const float DEGTORAD; //... }; [/code] [code] //foo.cpp const float Constants::PI = 3.1415f; //... [/code] … | |
Re: @OP you want this I think: [code] template<typename R, typename T> R cast(const T& input){ stringstream stream; stream << input; R ret = R(); stream >> ret; return ret; } int main(){ int i = cast<int>("12345"); float pi = cast<int>("3.1415"); } [/code] | |
Re: [code] void dofunc(int a, int b){a+=b;} void foo(int near,int far){dofunc(near,far);}//Syntax error, expected primary expression before , and ) void poo(int vnear,int vfar){dofunc(vnear,vfar);}//Compiles fine? int main(){} [/code] that works fine for me? Whats the real code ? | |
[B]Confession[/B]: I love girly songs( don't judge me). Your turn. | |
First of all, I am a confused christian, and I am creating this thread to see if I can clear out some fog in my head. So lets start. Claim: The bible is false in the sense that it was not written with the guidance of "god" Reasons for my … ![]() | |
Re: Your factorial is wrong. Since you are updating by 2, you are missing terms in your factorial. Separate the factorial into its own function. Or do this: [code] double sineSeries(double x, int n){ double xPower = 0.0; double factorial = 1.0; double sineComputed = 0.0; bool sign = true; for … | |
Re: [QUOTE=UltimateKnight;1582999]Hey all. When you have the whole program running, and is executed it's running at the black console window. How are the programs made so that they run with GUI interface and stuff like that? Are they exported differently and where are the images and things put together ? Thanks.[/QUOTE] … | |
Re: >>[B]#define J sqrt(-1.0)[/B] there is no such thing as sqrt(-1.0), the parameter to sqrt shouldn't be negative. Instead just imagine the second paramter of complex type is imaginary. [code] typedef std::complex<float,float> Complex; typedef std::vector<float> TimeDomainData; typedef std::vector<Complex> FrequencyDomainData; int main(){ const int SAMPLE_POINTS = 1024; const TimeDomainData data = generateTimeDomainData(SAMPLE_POINTS); … | |
Re: In the first while loop your exit condition is when cin fails. It will fail when it reads in something that its no supposed to. Its expecting a integer( a number ), and if you pass it a character, then cin fails and it sets the failure bits accordingly. Now … | |
![]() | Re: [QUOTE=Raim;1580108]Thanks, that sure helped me. The code is here for anyone that might want to take a look at it: [CODE]int n; double sum = 0; //promt user to enter the number. cin>>n; for (int i = 0; i<=n; i++) { sum+=i; } cout<<sum <<endl; //demonstrating the result[/CODE][/QUOTE] This gives … ![]() |
Re: [QUOTE=LevyDee;1581255]You can't compare character arrays like that. Your best bet is to create a function that will do a loop check of each element in the two arrays. And have it return a boolean. aka [code] bool isEqual(char onFile[], char checking[]) { for(int i = 0; i < (sizeof(onFile) / … | |
![]() | Re: [QUOTE=iamthwee;1579938]Is this too easy... Looks like the minimax algo more or less achieves perfect play once it plays all the games...[/QUOTE] Yea exactly, you don't even have to use minmax, following a simple series of rules can produce unbeatable tic-tac-toe AI. |
Re: [QUOTE=Spillman;1580295]Just learned that you can't use case/switch with strings in C++. So... used if/elseif: [CODE] if (theCategory=="colors") getCatArrAndVals(colors); else if (theCategory == "fruits") getCatArrAndVals(fruits); else if (theCategory == "veggies") getCatArrAndVals(veggies); [/CODE] If anyone has a sleeker way of doing this, please let me know. TIA[/QUOTE] Sure [code] #include <map> #include … | |
Re: To see if a number is even you can just check the remainder when divided by 2 or check the last bit. For floating number, you can just check the integer part, so there is no need to use fmod since comparing it to 0.0 might not do what you … | |
Re: You need to apply the following transformation. 1) Remove all nonalpha characters 2) Convert all character to lowercase 3) Compare it to its reverse( or compare begin + i to end - i ) To remove all nonalpha characters to a string you can use the following: [code] struct IsNotAlpha{ … | |
Re: I don't get you problem, this is what I get for input of 3000. [code] pppppp oooooo w w w eeeeeeee rrrrrrr cccccc oooooo p p o o w w w e r r c c o o p p o o w w w e r r c o … | |
Re: If your ultimately wanting to play sound then I would suggest using a library that handles reading and playing sounds for you already. A suggestion would be to use FMOD. Or if you just want to develop on windows then you can use the [i]PlaySound[/i] function | |
Re: If you are using sdl, then you can use sdl_mixer. But the suggested ones are openAL and FMOD | |
Re: Check if your compiler supports [URL="http://www.parashift.com/c++-faq-lite/templates.html#faq-35.14"]export keyword[/URL], although note that its being removed from the standard. | |
Re: You should do something like this : [code] const string& stringToAvoid = "#\n"; string line; while(getline(cin,line)){ if(stringToAvoid.find(line[0]) != string::npos) continue; } [/code] that way you can just add more character to [i]stringToAvoid[/i] instead more if's |
The End.