2,712 Posted Topics
Re: You can do something like this : [code] bool isPressedInsideCircle = false; while( game.stillRunning() ){ if( Z_KEY_PRESSED ){ if( fallingCircleIsWithinScoreBounds() ){ isPressedInsideCircle = true; player.increaseScore(); } } if( circleIsOutOfScreen ){ if( isPressedInsideCircle == false ){ player.setScore( 0 ); } circle.setLocation( TOP_OF_SCREEN ); } } [/code] | |
Re: In my last class, we made a ALU. We worked with 4 bit adder. It accepts 2 4-bit number and returned the addition of those number, but you knew that. One usefulness I used the cout was to detect an overflow. Since a 4 bit number has the max representation … | |
Re: So writing your language inside a text file and using C++ to read it and interpret it and compile it not an option? | |
Re: Although I am still in college, I can still give my opinion hoping it will help somehow. For hardware designer, you will need about half CSE and half EE. From physics 1, you might using basics law. I would think you will use more physics 2, since it will deal … | |
Re: When you say game, do you mean console ( just C++ ) or using a graphics library. If "using a graphics library", how much knowledge or experience do you have using that graphics library? Give more details. | |
So I was thinking, we should have a challenge of the day or week, for a specific language, that poses a unique problem. This way people can practice, and others can learn maybe something new from someone else's idea. What do you guys think ? For example in our C++ … | |
Re: OMG, this is so urgent. Let me help you quick before the world ends. This part : [code] char *fileName = new char; [/code] That makes fileName a char variable, not an array. What you meant to do was this : [code] char *fileName = new char[100]; [/code] But thats … | |
Re: From what I see , you do not need to return a 2d array. Consider just doing this : [code] void set_element(string array2D[][MAX_COL], const int MAX_ROW) { for (int i = 0 ; i < MAX_ROW ; i++) { for (int j = 0 ; j < MAX_COL ; j++) … | |
Re: If you know the RowSize and colSize you can do this, but I see no point. Using 2 for loops makes it more clear. [code] void print(int A[MAX_ROW][MAX_COL]) { int row = 0; int col = 0; for(row = 0, col = 0; row < MAX_ROW; ) { //increment row … | |
Re: For this problem, if you get 1, other will be simple. So focus on 1 function first. >>Round down to nearest 5 gives: 125 Before we go further. What happens if we say this : Round down to nearest 5 for number 124 ? Round down to nearest 5 for … | |
Re: There is also [URL="http://www.gamedev.net/community/forums/"]http://www.gamedev.net/community/forums/[/URL] which has really a lot of smart developers that has been programming for a while, and also developing games for a while in the industries. Although its not necessarily c++, post in the beginners section, then there is a 99.99% guarantee, that your problem will be … | |
Some of us were having some discussion about posting some challenge question for the community to participate in. This way people could learn from the more experienced person's solution. Here is the question that : Intro : [b] [ICODE]A multiplied Sum Of digits is the sum of the digits of … | |
Re: [code] cout<<"*"<<endl; cout<<" *"<<endl; cout<<" *"<<endl; cout<<" *"<<endl; cout<<"*"<<endl; [/code] | |
Re: In your main class, load in all of the textures in your init function. Then when displaying the objects, use glBindTexture(GL_TEXTURE_2D,id); where the id is the id of a certain texture. | |
Re: This code : [code] class A { virtual c Read(); } class B: public A { public c Read(){ D d ; return d; } } class C {} class D: public C {} void main (){ B b; D d = b.Read(); // how will i convert it?? } … | |
Re: [QUOTE=coolcool;1080266]Hi everyone, Am just a beginner in c++ and have wishes to become good in it..it doesn't mean i should become a expert but just a good programmer. also i have enrolled for a competition in the college which am studying which requires an application to be developed using cpp..can … | |
Re: If you std::strings, then you could just compare them as if you would compare it with numbers. [code] int x = 4; int y = 4; bool b = x == y; std::string str = "abc"; std::string str2 = "abc"; bool b2 = str == str2; [/code] | |
Re: Then using [URL="http://www.cplusplus.com/reference/iostream/manipulators/showbase/"]manipulators[/URL] will help you. | |
Re: They will pretty much teach you the same thing at least the concept part, like loops, if else statements, control flow, variables, ints, floats ,blah blah blah. I think if you take C++, then picking up C by your self is not hard. If you had to pick 1 , … | |
Re: [code] int a = 1; int b = 2; int *p1 = &a; int *p2 = &b; int *p3 = *p1 + *p2; [/code] | |
Re: Start over. Delete that file. Create a new C++ file. First post the simple code into it and run it. Check that it works. Now Paste the second equally simple code. Now "build" it, either from the tab above or press F7. Then run it. | |
Re: Change this : [code] char *MainMsg[20],*SearchChar; [/code] To [code] const int MAXSIZE = 100; char MainMsg[MAXSIZE]; char SearchChar[MAXSIZE]; [/code] Better yet, get rid of those and use std::strings. | |
Re: >>void Save_Game(); This is not how to call a function. Since your Save_Game takes an 2d array, you need call your function like this : [code] Save_Game( gameBoard) ; //where gameBoard is the board of tic-tac-toe [/code] | |
Re: start with this : >>You will add three functions which are: void set_hr(int h);//to set hr then validate it. void set_min(int m);//to set min then validate it. void set_sec(int s);//to set sec then validate it. | |
Re: First is the number -10 < n < 10 ? Is it within -10 and 10 but not including 10? Or can it be any number? | |
Re: get rid of all the unneeded " //----// " it makes the code unreadable. [code] #include<iostream> #include<fstream> #include<cstdlib> #include<cctype> #include<string> using namespace std; int main() { //Filestream Object Declaration ofstream alphabet( "C:\\alphabet.txt" ) ; //Variable Declarations string sentence ; //User Input Prompt cout << "Please type a compilation of alphabet … | |
Re: Usually, starters start up using regular arrays, because it easy, plus usually you don't need to worry about efficiency, and or resizing the array. But once, you get the idea about arrays, you might want to move up with vectors, and understand how to use them. They are just like … | |
Re: [code] //items are equal else if(list1=list2) [/code] or [code] // is items equal ? else if(list1== list2) [/code] | |
Re: >>CEquipment* equipment = &(random_from<CEquipment>(equipments)); This is what you are doing : [code] int * pointer = 0; //declared somewhere void foo(){ int a = 3; pointer= &a; //what you are doing }//end of the brackets [/code] now at the end of the brackets, a gets destroyed, and what does pointer … | |
Just wondering what other programmer do in their free time. This is basically what I do in my free time : 1) Procrastinate ( of course ) 2) Try to learn more things about programming 3) Practice programing 4) Play NBA2k9 and/or Call of Duty : modern warfare 2 (awesome … | |
Re: It works if you do it right : [code] #include<iostream> #include<ctime> using namespace std; class Random{ private: const unsigned int MAX; public: Random(const unsigned int maxLimit) : MAX(maxLimit) {} int getRandom(){ return rand() % MAX; } }; int main(){ srand(time(0)); Random myRand(100); for(int i = 0; i < 25; i++){ … | |
Re: Since the size of the file is unknown you need to use vectors to store the data. I also suggest you to read in the file into a string , from start untill you reach the ',' comma character. Therefore you will need to use a vectors of strings. [code] … | |
Re: This part : [code] if (cin.fail()){ do{ cout<<"Wrong Data Type of Input!"; cout << "Please Enter the Product ID Again : "; cin >> product[i].id;//whats wrong here?? }while(cin.fail()); } [/code] You need to clear the stream if it fails, so : [code] if (cin.fail()){ do{ cin.clear() ; //clear the stream … | |
Re: >>how did you choose your major? Took a C++ class, loved it, switched over from accounting to CSE. >>what if you like everything in a scope? I use brackets limit the scope. >>what if you're a geek !! Be proud of it, although "geek" is hard to define. >>seriously now … | |
Re: Your algorithm is incorrect. When you read in a string, you need to check the whole array if the string exist. I suggest you use a map, to store the the value as a key, then you won't have to much work since the map automatically does not add elements … | |
Re: Got rid of a lot of your errors : [code] #include <iostream> #include <iomanip> #include <string> #include <cctype> using namespace std; //function prototype goes outside main string format_name(string Name); int main() { string Name = ""; //local constants int Average = 0; const int MAX = 100; int At_Bat = … | |
Re: Listen to the error : "[B]no matching function[/B] for call to `toupper(std::string&)' " It tells you that there is no function that matches the prototype : toupper(std::string&). There is however, toupper(char ch); You will need to make a toupper(std::string&) function , using toupper(char ch). maybe something like this : [code] … | |
Re: First make a palindrome that is case and punctuation sensitive : You code revised a little : [code] #include <string.h> bool palindrome (const char *s) { int index = 0, length = 0; length = strlen (s); int halfLen = length/2; for (index = 0 ; index < halfLen; i++){ … | |
| |
Re: [code]float FindMaxMin(int x, int y, int z, float &max, float &min) { //FindMax if (x > y && x > z) {return x;} if (y > x && y > z) {return y;} else {return z;} //FindMin if (x < y && x < z) {return x;} if (y < … | |
Re: Yes, : [code] char space = ' '; for(unsigned int i = 0; i < str.size(); i++){ if(str[i] == space){ str[i] = '_' } } [/code] | |
Re: Code Tags : [code] /************************************************************************************************* This is a program I'm writing to calculate test grades and weight in certain tests. **************************************************************************************************/ #include <iostream> using namespace std; int OptionMenu(int); void GradeAve(float GA_number, float G_ave,float GA_sum, int GA_count); int main() { float GA_sum; float GA_ave; int menunumber=0; int GA_count=0; float GA_number=0; OptionMenu(menunumber); … | |
Re: Compare your code with just this : [code] //print 'a' through 'z' for(char ch = 'a' ; ch <= 'z'; ch++){ cout << ch << endl; } [/code] | |
Re: You almost have it, what you need to change is : [code] string found(float myarr[], float item, int length); { //need a for loop not a while for(int i=0; i<=(length-1);i++) { if (myarr[i] > item) return "TRUE"; } //will reach here if above does not return true return "FALSE"; } … | |
Re: Fix to : [code] if(winner == 0) [/code] Also make use of functions. | |
Re: >>line 44 `main' must return `int' refers to you having : "void main()"; it should be : [code] int main(){ //code return 0; } [/code] This part : [code] while (Num_Input =! QUIT) [/code] should be : [code] while (Num_Input != QUIT) //reads not equal to [/code] This :[code] void … |
The End.