Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Czar05

Member Since 20 Jun 2011
Offline Last Active May 23 2013 03:30 PM
-----

Topics I've Started

Should I dive into linear algebra or follow the prerequisite first?

12 October 2012 - 07:27 PM

I am currently a high school student taking Calculus with Application and code in my spare time. I am trying to dive deeper into game development and reading up on a lot of diverse topics. I have read on this forum that, unlike calculus, linear algebra has a bigger part in game development. The prerequisite for linear algebra is Calculus 2 and Calculus 3.

So my question is, should I hold off on linear algebra and focus on Calculus 2 and 3 or can I dive into linear algebra without needing the previous topics.

Thanks in Advance.

(Box2D) Trouble with the release mode build

22 August 2012 - 02:45 PM

I am having trouble getting the release mode build ready for Box2D. I have managed to get the debug mode build finished, but difficulty with the release. I followed this tutorial for debug.. http://aneelkkhatri....isual-studio-c/

I keep getting the following error message for the release build......

Anybody know what the problem is....Thanks in advance.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Found the problem, Thank you BitMaster for answering.

toupper() function?

04 August 2012 - 11:36 PM

I am having difficulty with the toupper() function. I can't use the string class with this particular function.

#include <iostream>
#include <cctype>
#include <string>

using namespace std;


void inputnshow(string & a);

int main()
{
	string  sent;

	cout << "The following program will convert a sentence and convert it to uppercase.\n";
	cout << " " << endl;
	inputnshow(sent);
  
  
  return 0;
}

void inputnshow(string & a)
{
	int n = 0;
  
	while(n < 1)
	{
	cout << " " << endl;
	cout << "Enter a string (q to quit).\n";
	getline(cin, a);
	toupper(a);
	cout << a << endl;
  
	cout << " " << endl;
  
	cout << a << endl;
	cout << "Next string (q to quit).\n";
	getline(cin, a);
	toupper(a);
	cout << a << endl;

	if(a == "q")
	{
	   cout << "Bye" << endl;
	   system("Pause");
	}

	}
  
}



I keep getting an error with the, string a, variable. I tried using a char array, but that requires an initialization and I am looking for user input.

Function Arrays problem

22 July 2012 - 08:22 PM

I am having trouble sending a user defined function to another user defined function. The other tricky part to this is sending an array to another function. Here is my code..

#include <iostream>

using namespace std;

const int size = 10;			  // Number of elements

int store_input(int [], int);	   // User input
int calculation(int[], int);			// Calculating average
void show(int []);				  // Displaying data

int main()
{
	int store_score[size] = {0,0,0,0,0,0,0,0,0,0};   // Store values array
	
	store_input(store_score, size);
	 calculation();			// Calculating average
	 show();				  // Displaying data


  

	

	system("Pause");
  return 0;
}


int store_input(int arr[], int size)
{
	int send_score = 0;					// Send to another function						  
	int i;
	cout << "Enter your score: " << endl;
	for(int i = 0; i < size; i++)
	{
	   cin >> arr[i];
	   send_score = send_score + arr[i];
	}

	return send_score;
}

int calculation(int send_score, int size)
{
  
   int hold = store_input(store_score, size);
   int average = 0;

   average = hold / 10;
  
   return average;

}

void show()
{
	int show = calculation(int send_score, int size);


	cout << "The average is: " << show << endl;

}


**** Sorry for the sloppy code, I was trying to give you an idea of what I was trying to do ********

In this program, I am trying to send user input from the store_input() to the calculation(). The calculation function will then return the average which it will deliver to the show(). The show function will then display the average. I need an explanation on how I can send one function to another ? Also a quick explanation on how I should treat function arrays especially when transferring arrays to another function.

Why is Getline() skipping user input?

18 July 2012 - 08:48 PM

When I run my program, a portion of the code( that involves getline()) is skipped. The first getline() works fine but the others don't receive user input and don't display otherthing either. I don't see the error in the code:



#include <iostream>
#include <string>

using namespace std;

struct CandyBar
{
	string brand_nam;
	float weight;
	int calories;
};

int main()
{
	
	CandyBar * snack = new CandyBar[3];		// Dynamic Array holding structures
  
	cout << "What is the name of the brand: " << endl;
	getline(cin, snack[0].brand_nam);				  // First element
	cout << "What is the weight of the brand: " << endl;
	cin >> snack[0].weight;
	cout << "What is the calories of the brand: " << endl;
	cin >> snack[0].calories;

	cout << " " << endl;

	cout << "What is the name of the brand: " << endl;
	getline(cin, snack[1].brand_nam);
	cout << "What is the weight of the brand: " << endl;
	cin >> snack[1].weight;
	cout << "What is the calories of the brand: " << endl;
	cin >> snack[1].calories;
  
	cout << " " << endl;

	cout << "What is the name of the brand: " << endl;
	getline(cin, snack[2].brand_nam);
	cout << "What is the weight of the brand: " << endl;
	cin >> snack[2].weight;
	cout << "What is the calories of the brand: " << endl;
	cin >> snack[2].calories;

	cout << " " << endl;
	cout << " " << endl;

	cout << "First brand is: "<< snack[0].brand_nam << " which has " << snack[0].weight << " Ibs " << " and " << snack[0].calories << " Cal " << endl;
	cout << " " << endl;
	cout << "Second brand is: " << snack[1].brand_nam << " which has " << snack[1].weight << " Ibs " << " and " << snack[1].calories << " Cal " << endl;
	cout << " " << endl;
	cout << "Third brand is: " << snack[2].brand_nam << " which has " << snack[2].weight << " Ibs " << " and " << snack[2].calories << " Cal " << endl;
  
	delete []snack;

	system("Pause");
return 0;
}


PARTNERS