2,712 Posted Topics

Member Avatar for ge6a93

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]

Member Avatar for mrnutty
0
113
Member Avatar for Fulladder

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 …

Member Avatar for Fulladder
0
84
Member Avatar for switch3d

So writing your language inside a text file and using C++ to read it and interpret it and compile it not an option?

Member Avatar for pogson
0
117
Member Avatar for random100

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 …

Member Avatar for pogson
0
156
Member Avatar for abel kaleab
Member Avatar for baron919

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.

Member Avatar for mrnutty
-2
138
Member Avatar for mrnutty

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++ …

Member Avatar for cwarn23
1
283
Member Avatar for ayesha91

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 …

Member Avatar for GrubSchumi
-3
140
Member Avatar for timtianchen

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++) …

Member Avatar for monkey_king
0
148
Member Avatar for kde

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 …

Member Avatar for jonsca
0
102
Member Avatar for Darth Vader

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 …

Member Avatar for Darth Vader
0
332
Member Avatar for tech291083

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 …

Member Avatar for tech291083
0
198
Member Avatar for mrnutty

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 …

Member Avatar for mrnutty
0
148
Member Avatar for Adrhian77

[code] cout<<"*"<<endl; cout<<" *"<<endl; cout<<" *"<<endl; cout<<" *"<<endl; cout<<"*"<<endl; [/code]

Member Avatar for Nick Evan
1
103
Member Avatar for Valaraukar

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.

Member Avatar for Valaraukar
0
260
Member Avatar for Alex_

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?? } …

Member Avatar for Narue
0
113
Member Avatar for coolcool

[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 …

Member Avatar for DanielGreen
0
112
Member Avatar for WhatTheDeuce

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]

Member Avatar for mrnutty
0
137
Member Avatar for jolianne

Then using [URL="http://www.cplusplus.com/reference/iostream/manipulators/showbase/"]manipulators[/URL] will help you.

Member Avatar for mrnutty
0
77
Member Avatar for soley

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 , …

Member Avatar for Wards
0
112
Member Avatar for StaticX

[code] int a = 1; int b = 2; int *p1 = &a; int *p2 = &b; int *p3 = *p1 + *p2; [/code]

Member Avatar for necrolin
0
105
Member Avatar for basedon

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.

Member Avatar for jonsca
0
194
Member Avatar for octavia

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.

Member Avatar for mrnutty
0
182
Member Avatar for iammfa
Member Avatar for Spiderpig085

>>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]

Member Avatar for mrnutty
0
983
Member Avatar for fadia

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.

Member Avatar for fadia
0
103
Member Avatar for ankiwalia

First is the number -10 < n < 10 ? Is it within -10 and 10 but not including 10? Or can it be any number?

Member Avatar for mrnutty
0
90
Member Avatar for EngneerNitemare

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 …

Member Avatar for EngneerNitemare
0
2K
Member Avatar for kungfudoug

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 …

Member Avatar for Bench
0
115
Member Avatar for lotrsimp12345

[code] //items are equal else if(list1=list2) [/code] or [code] // is items equal ? else if(list1== list2) [/code]

Member Avatar for TheArchitect
0
497
Member Avatar for Japus

>>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 …

Member Avatar for thelamb
0
2K
Member Avatar for mrnutty

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 …

Member Avatar for ddanbe
1
309
Member Avatar for Skeen

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++){ …

Member Avatar for Skeen
0
112
Member Avatar for grafas7

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] …

Member Avatar for mrnutty
0
100
Member Avatar for samsons17

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 …

Member Avatar for valtikz
0
213
Member Avatar for new programer

>>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 …

Member Avatar for new programer
0
475
Member Avatar for Lilal

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 …

Member Avatar for Lerner
0
346
Member Avatar for eduard77
Member Avatar for Lerner
0
84
Member Avatar for Snapster5

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 = …

Member Avatar for Lerner
0
147
Member Avatar for Snapster5

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] …

Member Avatar for mrnutty
0
93
Member Avatar for dennis.d.elston

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++){ …

Member Avatar for mrnutty
0
126
Member Avatar for nunchuckie
Member Avatar for kamikazekazuo

[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 < …

Member Avatar for jonsca
0
156
Member Avatar for saisai81
Member Avatar for travism

Yes, : [code] char space = ' '; for(unsigned int i = 0; i < str.size(); i++){ if(str[i] == space){ str[i] = '_' } } [/code]

Member Avatar for travism
0
7K
Member Avatar for dalymiddleboro

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); …

Member Avatar for mrnutty
0
116
Member Avatar for EngneerNitemare

Compare your code with just this : [code] //print 'a' through 'z' for(char ch = 'a' ; ch <= 'z'; ch++){ cout << ch << endl; } [/code]

Member Avatar for mrnutty
0
139
Member Avatar for ukbassman88

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"; } …

Member Avatar for ukbassman88
0
95
Member Avatar for rena0514
Member Avatar for rena0514
0
155
Member Avatar for Snapster5

>>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 …

Member Avatar for Snapster5
0
146

The End.