sfuo 111 Practically a Master Poster

I threw a for loop in and a function but if you aren't allowed to use functions you can use the same method in the 1st few posts.

This adds 7 to each digit then gets the remainder of each new digit by using mod 10 and then puts them in the 3412 order.

#include <iostream>
using namespace std;

int E(int exp) //function returns 10^exp
{
    if( exp <= 0 )
        return 1;
    int r = 1;
    for( int i = 0; i < exp; i++ )
        r *= 10;
    return r;
}

int main()
{
    int num;
    int digits[4];
    cout << "Enter a 4 digit number to be encrypted: ";
    cin >> num;

    for( int i = 0; i < 4; i++ )
        digits[3-i] = (((num%E(i+1))/E(i))+7)%10; //takes the digit from the input adds 7 and "mods" it to a 1 digit number

    int temp[2] = {digits[0], digits[1]}; //stores these 2 digits because they get overwritten when changing the order
    digits[0] = digits[2];
    digits[2] = temp[0];
    digits[1] = digits[3];
    digits[3] = temp[1];

    for( int i = 0; i < 4; i++ )
        cout << digits[i] << endl;

    return 0;
}
sfuo 111 Practically a Master Poster

As visitor11 said you need to put the variable to be assigned on the left hand side of the equals sign otherwise it will try to assign number%10 and it cannot do that.

C++ uses operators to do multiplication division addition subtraction and it does not use brackets for multiplication. You can probably overload the bracket operator to do multiplication but that just creates more work when '*' already does the job.

One thing I noticed with your encryptnum is that if any of the digits are 3 or more then its gonna carry the tens digit over to the next number and I'm not sure if you want that. If you do just leave what I am about to post and if you do not use the mod operator '%' (ie dig3 = (dig3 + 7) % 10) to give you a 1 digit number. encryptnum = (dig3 + 7) * (int)pow(10.0, 3.0) + (dig4 + 7) * (int)pow(10.0, 2.0) + (dig1 + 7) * (int)pow(10.0, 1.0) + (dig2 + 7); You will need to include the math header ---> #include <cmath>
for the pow(double, double) function.

Also you are using end1 <--- with the number one
when it is supposed to be endl <--- with the letter 'L' for line

sfuo 111 Practically a Master Poster

make line 7

float FahrenheitToCelsius( float );
sfuo 111 Practically a Master Poster

Also your formula for converting is wrong it is 5.0/9.0 not 5.0/8.0.

sfuo 111 Practically a Master Poster

You need to start with a simple program to understand what is going on because some of the questions you are asking are extremely basic where if you had looked at other examples (easier) you would know generally what is going on with it.

'1' = player 1
'2' = player 2
'w' = wall

It says that right in the comments

This could be explained but I would not consider this source code a good learning example.

sfuo 111 Practically a Master Poster

I'm not 100% sure why its not working for you and I can't figure out how to fix any of the errors in Example::render onResize WndProc and all that if I don't actually know the error message, unless you are saying that they are all getting linker errors.

I was getting warning when compiling so I changed your GLWindow() function so it sets the variables within the brackets rather than in the unique way you had before.

Also you were using CreateWindowEx() and passing NULL for the extended styles when you can just use CreateWindow() because that parameter just doesn't exist in the function.

I've attached the source code from what you posted with the changes I made. I also included the project file (code blocks) that if you do use the same compiler then you can take a look at that and compare to see if you have something different.

sfuo 111 Practically a Master Poster

So your print_tokens() function is supposed to output the lines to a file? I just see so much stuff wrong with the way you did it.

Edit: Can you include a sample input file so I can test it?

sfuo 111 Practically a Master Poster

You should really format your code so other people can read it.

I commented in a few things that I did and do not put function prototypes within other functions.

#include <iostream>
#include <fstream>
#include <string>
#include <iostream>
#include <string>
#include <cctype> // for std::isspace(), etc.

void print_tokens(const std::string &data); //move the prototype up here (do not declare prototypes within other functions)

int main(int argc, char *argv[])
{
	if(argc != 2)
	{
		std::cerr << "Usage: " << argv[0] << " input-file\n";
		return 1;
	}

	// open file
	std::ifstream input(argv[1]);
	std::string line; //only need to declare line once

	if(!input.is_open())
	{
		std::cerr << "Error opening file \"" << argv[1] << "\"\n";
	}

	while(std::getline(input, line))
	{
		std::cout << "Got line: [" << line << "]\n";
	}

	while(std::getline(std::cin, line))
	{
		print_tokens(line);
	}

	input.close(); //close your input stream when you are done with it

	return 0;
}

void print_tokens(const std::string &data)
{
	enum
	{
		MODE_OUTSIDE,
		MODE_IN_WORD,
		MODE_SYMBOL
	} mode = MODE_OUTSIDE; //I wouldn't have nested this enum within a function but depends on if you are only going to use it for this one thing

	std::string::size_type x = 0;
	while(x < data.length())
	{
		char c = data[x];
		switch(mode)
		{
			case MODE_OUTSIDE:
				if(std::isspace(c))
				{
					x++;
				}
				else if(std::isalnum(c))
				{
					mode = MODE_IN_WORD;
					std::cout << '"';
				}
				else
				{
					mode = MODE_SYMBOL;
				}
				break;

			case MODE_IN_WORD:
				if(std::isalnum(c))
				{
					std::cout << c;
					x++;
				}
				else
				{
					std::cout << '"' << std::endl;
					mode = MODE_OUTSIDE;
				}
				break;

			case MODE_SYMBOL:
				if(!std::isalnum(c) && !std::isspace(c))
				{
					std::cout << "[" << …
sfuo 111 Practically a Master Poster

If you aren't using the animate function right now comment it out or make the function and just don't have anything in it (currently you have the prototype but no real definition and that is what is giving the error). Also when I read through your code your stick man is being drawn behind the camera so change stickFig1.render(1.0f, 1.0f, 1.0f); into stickFig1.render(0.0f, 0.0f, -30.0f); Also I was getting a whole bunch of warning but I'm not gonna go about messing with it since it works right now.

Edit: Both of the functions are in the example.cpp file and the line stickFig1.animate(dt); in the function prepare(float) should be commented out. In the function render() stickFig1.render(float, float, float) should be changed as stated above.

sfuo 111 Practically a Master Poster

You can create a window without buttons or a boarder and create your own buttons using the mac images and then bind windows functions to them.

sfuo 111 Practically a Master Poster

You have your for loops all messed up so it is outputting sections more than once in a row.

#include <iostream>
using namespace std;

int main()
{
	int num = 0;
	cout << "How big do you want the pyramid? ";
	cin >> num;

	for( int i = 0; i < num; i++ )
	{
		for( int c = 0; c <= i; c++ )
			cout << c << " ";
		cout << endl;

		i++;
		for( int j = 0; i < num && j <= i; j++ )
			cout << "*";
		if( i < num )
			cout << endl;
	}
	
	for( int i = num-1; i >= 0; i-- )
	{
		for( int c = 0; c < i; c++ )
			cout << "*";
		cout << endl;
	}

	return 0;
}
sfuo 111 Practically a Master Poster

I bought the red book and blue book and I did get the OpenGL tutorials off gametutorials.com I would say they are good for learning a bit of stuff but not worth 35 bucks (35 for just OpenGL and DirectX tutorials). NeHe's website is really bad and I would suggest just using the books even tho they use glut. I would look at NeHe's first tutorial just to get the core code for making a window using OpenGL (pixel format and all that) and then use the books and instead of using GLUT transfer it over into the Win32 code.

sfuo 111 Practically a Master Poster

You have lots of unused variables and in here you had 2 for-loops that were not needed.

cout<<"Starting balance for Account 1: "<<banker1.accountBalance<<endl;
cout<<"Starting balance for Account 2: "<<banker2.accountBalance<<endl;

double newMonthlyBalance1 = banker1.accountBalance;
double newMonthlyBalance2 = banker2.accountBalance;

for(year = 1; year <= numberOfYears; year ++)
{
    cout<<"Year "<<year<<"	"<<endl;
    for(month = 1; month <= 12; month ++)
    {
        cout<<"Month "<<month<<"	"<<endl;
        banker1.accountBalance = (banker1.accountBalance * (1 + monthlyInterestRate1)) + monthlyDepositAmount - monthlyWithdrawalAmount;
	cout<<"Balance for first account: "<<banker1.accountBalance<<endl;

	banker2.accountBalance = (banker2.accountBalance * (1 + monthlyInterestRate2)) + monthlyDepositAmount - monthlyWithdrawalAmount;
	cout<<"Balance for second account: "<<banker2.accountBalance<<endl;

    }
    cout<<endl;
}
sfuo 111 Practically a Master Poster

"string.h" is for c and <cstring> is for C++.

Since you can use C code in C++ you can get away with using "string.h" but you should use <cstring> because you might run into problems.

Same thing goes with <cstdlib> (this is correct) because it can be used as "stdlib.h" (c version) and "iostream.h".

system() is for windows only and anything that you input into that function can be inputted into the command prompt window (type cmd in run).

I don't know any php but I'm 99% sure system() is not equivalent to include in php.

sfuo 111 Practically a Master Poster

Don't use #include "string.h" use <cstring> for the c-string library and #include <string> for the c++ string library.

Also read my post above that corrects your if statement because that will compile but it will be true no matter what.

Edit: you need to either have using namespace std; up with your includes or using std::cout, using std::endl or just type std::cout / std::endl every time you want to use those functions.

sfuo 111 Practically a Master Poster

You guys know this post is 4 years old right?

sfuo 111 Practically a Master Poster

Missed the end quote so that would return an error.

NicAx64 commented: ops +2
sfuo 111 Practically a Master Poster

Because ppoly1 points to rect and ppoly2 points to trgl.

These are two separate instances of the class and what happens to one only happens to that class unless you were to set the width to a static int then it would change for all instances of that class.

sfuo 111 Practically a Master Poster

ppoly1 is a pointer to a CPolygon.
The class CPolygon does not have an area() function so if you try to call that directly it will error.
You can call the function set_values(int, int) because in the CPolygon class that function exists.
You can point to rect or trgl because they are built off of the CPolygon class (they are CPolygon plus whatever you add to it in the new class).
This means that you can call functions with a higher class (CRectangle) from a lower class (CPolygon) but not the other way around unless they are defined virtually.

sfuo 111 Practically a Master Poster

Funny thing is that when I saw his code I knew it was from here and it is under the section Polymorphism. If you read on a bit it goes into all the virtual functions and all that so finish the section and it will make more sense.

sfuo 111 Practically a Master Poster

#1 you misspelled ppoly1 in cout << pploy1->area() << endl; so that should be giving you an error.

In order for the code to work the way you want it to you would need to make a pure virtual function in the class CPolygon: virtual int area() = 0; By doing this you cannot have an instance of CPolygon because it has a pure virtual function but you are allowed to have pointers to that class type or of a class that inherits CPolygon (ie CRectangle or CTriangle).

Right now it is trying to find that function in the CPolygon class and it doesn't exist so you cannot do it.

sfuo 111 Practically a Master Poster

This prompts you to type in the polynomial then it finds and replaces all "x^" with a " ". Then it loads the modified string into a stringstream and then populates the vector of monomials.

#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

struct monomial
{
	int coeff;
	int exp;
};

int main()
{
	stringstream ss;
	int numTerms = 0;
	string input = "";

	cout << "How many terms will the polynomial have?" << endl;
	cin >> numTerms;
	cin.ignore();

	vector<monomial> polynomial(numTerms);
	cout << "Enter the polynomial: ";
	getline(cin, input);

	for( unsigned int i = 0; i < input.size(); i++ )
		if( input.substr(i, 2) == "x^" )
			input.replace(i, 2, " "); //replace all x^ with a space

	ss << input; //add input to the stream

	for( unsigned int i = 0; ss >> polynomial[i].coeff; i++ ) //while there is still information to be read from the stream
		ss >> polynomial[i].exp;

	for( unsigned int i = 0; i < polynomial.size(); i++ ) //output
	{
		cout << polynomial[i].coeff << "x^" << polynomial[i].exp;
		if( i != polynomial.size()-1 )
			cout << " + ";
		else
			cout << endl;
	}
	cout << endl;

	return 0;
}
sfuo 111 Practically a Master Poster

Here is something I threw together really quick using a vector and a structure. Shouldn't be that hard to transfer it over to using a linked list.

#include <iostream>
#include <vector>

using namespace std;

struct monomial
{
	int coeff;
	int exp;
};

int main()
{
	int numCoeff = 0;

	cout << "How many coefficients will the polynomial have?" << endl;
	cin >> numCoeff;
	vector<monomial> polynomial(numCoeff);

	for( unsigned int i = 0; i < polynomial.size(); i++ )
	{
		cout << "Enter the coefficient of term " << i+1 << ": ";
		cin >> polynomial[i].coeff;
		cout << "Enter the exponent of term " << i+1 << ": ";
		cin >> polynomial[i].exp;
		cout << endl;
	}

	for( unsigned int i = 0; i < polynomial.size(); i++ )
	{
		cout << polynomial[i].coeff << "x^" << polynomial[i].exp;
		if( i != polynomial.size()-1 )
			cout << " + ";
		else
			cout << endl;
	}
	cout << endl;

	return 0;
}
sfuo 111 Practically a Master Poster

Make sure you have the header <iostream> and I'm pretty sure its calc.exe not calculator.exe unless that is the name of your program.

Also if (operation != '+' || '-' || '*' || '/' ) Does not do what you think it will. You want to have if( operation != '+' || operation != '-' || operation != '*' || operation != '/' ) and if( repeat = 1 ) Should be if( repeat == 1 ) = is for assigning
== is for comparing

sfuo 111 Practically a Master Poster

Here is a thread that talks about the floating point types here. And if you want the decimals to show you can use the <iomanip> header cout << setprecision(5) << fixed; You can check out this to get more manipulators and see what the ones I posted do.

sfuo 111 Practically a Master Poster

I just put both files in one for this post.

One huge thing you have to think about is how you format your code and variable names especially when you are going to post on a forum asking for help. I tried to clean it up with some white space to make it easier to read.

The only real errors you have is that you are not assigning values to variables that you are checking.

#include <iostream>
using namespace std;

class array
{
	int i, a[100], n, d, t, r, c, e[100][100], f[100][100], s, g[100][100], b[100], j, r1, c1;
	char p;

	public:
	void pro();
	void enter();
	void arrA( int );
	void arrB( int );
	void arrAA( int, int );
	void arrBB( int, int );
	void dis();
};

void array::enter()
{
	cout << "Enter the degree of array";
	cin >> d;
	if( d == 1 )
	{
		cout << "Enter the no of elements you wish to input(less than 100)\n";
		cin >> n;
		t++;
	}

	else if( d == 2 )
	{
		//did you want to put some code in here where you assign s?
		if( s == 0 ) //s is not assigned a value
		{
			cout << "\nEnter the no of rows\n";
			cin >> r;
			cout << "\nEnter the no of columns\n";
			cin >> c;
		}
		else if( s == 1 ) //s is not assigned a value
		{
			cout << "\nEnter the no of rows\n";
			cin >> r1;
			cout << "\nEnter the no of columns\n"; …
sfuo 111 Practically a Master Poster

I posted a solution in your original thread and what you have there does not do what you think it does.

You need to use the new operator since NewArray is being declared locally in your function and therefore is deleted at the end of the function. If you use the new operator it allocated memory that lasts until you use the delete[] operator (or until the program is closed).

sfuo 111 Practically a Master Poster

For this you need to use the new operator and when you are done with it make sure to delete the allocated memory or you will run into problems later.

#include <iostream>
using namespace std;

int* reverseArray(int*, int);

int main()
{
	const int size = 5;
	int array1[size] = {10, 20, 30 , 40, 50};
	int* numptr = array1;

	for( int i = 0; i < size; i++ )
		cout << numptr[i] << endl;
	cout << endl;

	numptr = reverseArray(array1, size); //assigns numptr to the memory location of the return

	for( int i = 0; i < size; i++ )
		cout << numptr[i] << endl;

	delete[] numptr; //remember to delete the block of memory allocated before pointing to something else otherwise you will have a leak

	numptr = 0; //point numptr to 0 until you need to assign it again later

	//add pause if needed
	return 0;
}

int* reverseArray(int* in, int size)
{
	int *newArray = new int[size]; //allocate memory using the new operator

	for( int oldIndex = size-1, newIndex = 0; oldIndex >= 0; oldIndex--, newIndex++ )
		newArray[newIndex] = in[oldIndex];

	return newArray;
}
sfuo 111 Practically a Master Poster

Look at your function prototype it does not match your function below. int reverseArray(int, int, int *); should be int reverseArray(int[5], int, int *); Edit: or just int reverseArray(int[], int, int *);

sfuo 111 Practically a Master Poster

@caut_baia - he said the data types that he had to use so I don't think using a structure would be following those guide lines.

@op - Not sure if you are allowed to use a pointer but I threw it in with a switch otherwise you would have to copy paste a bunch of code since the score arrays cannot be used in a for loop effectively. I also added another score array in because you only had 4 and changed some variable names to (ex NUM_STUDENTS instead of STUDENT_NAME)

#include <iostream>
using namespace std;

 int main()
 {
	const int NUM_STUDENTS = 5;				//number of students
	const int NUM_SCORES = 4;				//number of scores entered by user
	const int STRING_SIZE = 15;				//maximum numer of characters
	char names[NUM_STUDENTS][STRING_SIZE];	//array for the names of the students
	char letter_grade[NUM_STUDENTS];		//array for the letter grade
	double score0[NUM_SCORES],
		   score1[NUM_SCORES],
		   score2[NUM_SCORES],
		   score3[NUM_SCORES],
		   score4[NUM_SCORES];
	double average[NUM_SCORES];

	double *score = 0; //points to the score based on the student

	//Loop that will get the name of the student, test scores, and average them.
	 for( int studentIndex = 0; studentIndex < NUM_STUDENTS; studentIndex++ )
	 {
		average[studentIndex] = 0;
		cout << "Enter the name of student " << (studentIndex + 1) << " : ";
		cin >> names[studentIndex];
		cout << "Enter the test scores for " << names[studentIndex] << ":" << endl;

		switch(studentIndex)
		{
			case 0:
				score = score0;
				break;
			case 1:
				score = score1;
				break;
			case 2:
				score = score2;
				break;
			case 3:
				score = …
sfuo 111 Practically a Master Poster

You do not output an array like that. You have to go through each element and output it. array1 just points to the first element in the memory block.

for( int i = 0; i < size; i++ )
    cout << array1[i] << endl;

This should do exactly what you want.

sfuo 111 Practically a Master Poster

I haven't ever done this but I know it is called a Singleton. I looked it up on wiki and they have an example there. here

sfuo 111 Practically a Master Poster

I find it useful to see source code and read over it trying to figure out what is going on. I would recommend taking this and playing around with it to see how stuff works.

Also a website that I find very useful is http://www.cplusplus.com/doc/tutorial/. It goes over lots of the basics and there is also a reference section that goes over STL and many other things.

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	int num, total = 0;
	ifstream in("input.dat"); //open "intput.dat" for reading
	ofstream out("output.dat"); //open "output.dat" for writing
	while(in >> num) //while there is still information in the file to be read
	{
		if( num%10 + num/10 >= 10 ) //sum of the 2 digits is less than 10
			num = num%10 + num/10; //split and add

		total += num;
		if( total%10 + total/10 >= 10 ) //sum of the 2 digits is less than 10
			total = total%10 + total/10; //split and add

		out << (total%10 + total/10) << " "; //output the result of total
	}
	out.close(); //close after use
	in.close(); //close after use

	return 0;
}
sfuo 111 Practically a Master Poster

You don't need to make them a string you could just use %10 and /10 to figure out the 1s and 10s digit then add those 2 numbers together to check.

Edit: Didn't even read the whole post until after mine and it says right in there how to do it.

thelamb commented: Good job quoting his assignment. +0
sfuo 111 Practically a Master Poster

Not sure if you need to use arrays and cstrings for your assignment but in C++ there is a string class and vector class that I think would work way better for this.

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	srand(time(NULL)); //seed random
	vector<string> article(5); //make a vector with 5 elements to hold the articles
	article[0] = "the"; article[1] = "a"; article[2] = "one"; article[3] = "some"; article[4] = "any";

	vector<string> noun(5); //make a vector with 5 elements to hold the nouns
	noun[0] = "boy"; noun[1] = "girl"; noun[2] = "dog"; noun[3] = "town"; noun[4] = "truck";

	vector<string> verb(5); //make a vector with 5 elements to hold the verbs
	verb[0] = "drove"; verb[1] = "jumped"; verb[2] = "ran"; verb[3] = "walked"; verb[4] = "flew";

	vector<string> preposition(5); //make a vector with 5 elements to hold the prepositions
	preposition[0] = "to"; preposition[1] = "from"; preposition[2] = "over"; preposition[3] = "under"; preposition[4] = "on";

	vector<string> sentence(20); //make a vector with 20 elements to hold the sentences

	for( unsigned int i = 0; i < sentence.size(); i++ )
	{
		sentence[i] = article[rand()%5] + " " + noun[rand()%5] + " " + verb[rand()%5] + " " + preposition[rand()%5] + " " + noun[rand()%5] + "."; //add all the strings together
		cout << sentence[i] << endl; //output the sentence we just made
	}
	//add pause if needed
	return 0;
}

Storing all the information into the vectors is kind of a pain but they are easy to use.

sfuo 111 Practically a Master Poster

I know it is homework and you didn't post what you have but its really simple and if you don't know how to start this then I wouldn't really expect any work done already.

#include <iostream>
using namespace std;

int main()
{
    for( int i = 1; i < 10; i++ )
    {
        cout << i << endl;
    }
    //add a pause here if you need to
    return 0;
}
sfuo 111 Practically a Master Poster

I use Code::Blocks so according to you this wouldn't work and also your vector class does not even have the operator that I am looking for.

I want to be able to type

vec3f sean(1.0, 1.0, 1.0);
glVector3fv(sean);

So the vec3f class needs to return a const GLfloat* without leaking memory (because I already got that far).

Mike I tried what you posted and it didn't work.

xuangcong thanks for posting what you got but sorry that is not what I am looking for.

sfuo 111 Practically a Master Poster

Yeah currently I just use this macro but I have to do it for glNormal and glColor

#define sfVertex3fv(x) glVertex3f(x._x, x._y, x._z)
sfuo 111 Practically a Master Poster

Yeah sure.

sfuo 111 Practically a Master Poster

You should make a variable called playerHand or something that will keep track of what the players current hand is worth. That way you can just add the random integer to it and then make a new random integer while still keeping the value of the players hand.

The very first game I ever made was blackjack and I made a deck of 52 cards and used rand() % 52 to pick a card out of the deck (array[52]) and just added the value of the card to the players hand. If you want I can attach the source code for that even tho I haven't looked at it for a really long time so some stuff could be poorly written.

sfuo 111 Practically a Master Poster

Hey guys I have come up with a solution for the problem I have but I would like to know how I could do this the way I initially had it set up but without the leak of course.

vec3f.h

class vec3f
{
	public:
	GLfloat _x, _y, _z;

	vec3f(){};

	vec3f( GLfloat x, GLfloat y, GLfloat z )
	{
		_x = x;
		_y = y;
		_z = z;
	}

	*operator GLfloat()
	{
		GLfloat *_r = new GLfloat[3]; //the problem
		_r[0] = _x;
		_r[1] = _y;
		_r[2] = _z;
		return _r;
	}
}

Now I know I am calling the new operator without calling the delete operator but if I put in a deconstructor that frees _r (when declared as part of the class) it crashes because it is pointing to something that was freed.

Anyways I am trying to use this in the OpenGL function glVertex3fv( const GLfloat *v ) .

I don't know if there is an operator that will do exactly what I want since I do not know all of them.

Any help would be great. Thanks.

sfuo 111 Practically a Master Poster

Not sure if you want to add the extra number in so you know how long the vector is. Otherwise you would have to read it in and check for the commas.

#include <iostream>
#include <vector>
#include <deque>
#include <fstream>

using namespace std;

struct Entry
{
	int addr;
	int dst;
	int size;
	vector<int> path;
};

/* "test.txt"

1 A0003 128 3 4 4 4
2 A0005 128 4 1 8 3 2
3 A0002 128 2 2 2

*/

int main()
{
	deque<Entry> myFile;
	ifstream in("test.txt");
	Entry temp;
	while( in >> temp.addr )
	{
		int counter;
		in >> hex >> temp.dst >> dec >> temp.size >> counter;
		temp.path = vector<int>(counter);

		for( int i = 0; i < counter; i++ )
			in >> temp.path[i];

		myFile.push_back(temp);
	}

	in.close();

	//not sure if you wanted this to print to a file or something but its exactly the same just make an ofstream and replace cout
	for( unsigned int i = 0; i < myFile.size(); i++ )
	{
		cout << "Show the parameters " << myFile[i].addr << endl;
		cout << hex << myFile[i].dst << dec << endl;
		cout << myFile[i].size << endl;
		for( unsigned int c = 0; c < myFile[i].path.size(); c++ )
			cout << myFile[i].path[c] << " ";
		cout << endl;
	}

	return 0;
}
sfuo 111 Practically a Master Poster

Yeah I thought about doing that mike but unless you wanna throw in a vector or something to sort them I think just running through the list looks better.

sfuo 111 Practically a Master Poster
void printAllFactors( int in )
{
	//remove the = if you want it to not show "in" as being a factor  
	for( int i = 1; i <= in; i++ ) //start the counter at 1 and loop it until it reaches the inputted number
		if( in % i == 0 ) //check if i (the counter) divides evenly into the inputted number
			cout << i << " "; //if it does then it is a factor
	cout << endl;
}

The reason why I'm posting this solution is because from looking at your pseudo code it doesn't really look like you know what you are trying to do.

If you want it to print in descending order (this is ascending) then flip the loop so it starts at i = in (or i = in-1 if you want it to not show "in" as being a factor), stop at i <= 1 and increment it by i--.

sfuo 111 Practically a Master Poster

Recursion is cool but when I was testing out using loops vs it any number 4 and above took longer to calculate when using the recursive function (time taken is not noticeable) and recursion takes up more memory because it keeps adding to the stack.

This is the code I used

unsigned int factorial( unsigned int num )
{
	if( num == 0 || num == 1 )
		return 1;
	unsigned int result = 1;
	for( unsigned int i = num; i > 1; i-- )
		result *= i;
	return result;
}

I used unsigned int just because you cannot use negative values or get a negative value from the factorial function.

sfuo 111 Practically a Master Poster

Well since everyone is posting their solution, might as well post mines :

void printPattern(char ch1, char ch2, const int MAX){	
	for(int r = 0; r != MAX; ++r){
		for(int c = 0; c != MAX; ++c){
			cout << (c % 2 == 0 ? ch1 : ch2 ) ;
		}
		cout << endl;
	}
}

Problem here is that it does not change based on the rows. For even rows it should output the 1st char and odd ones should output 2nd char.

sfuo 111 Practically a Master Poster

I came up with a way to output the characters and semi commented what is going on.

#include <iostream>

using namespace std;

int main()
{
    int n;
    char in[2]; //change to an array (see output)
    cout << "Enter two characters and an integer: " << flush;
    cin >> in[0] >> in[1] >> n;

    for( int i = 0; i < n; i++ )
    {
    	for( int c = 0; c < n; c++ )
    		cout << in[((c%2)+(i%2))%2]; //output the character based on the row and col and then mod by 2 so it does not leave the array's range
    	cout << endl;
    }
    return 0;
}
sfuo 111 Practically a Master Poster

Doesn't 3/12 reduce to 1/4 and 9/12 to 3/4.

Also 2/12 reduces to 1/6 not 1/12 (typo I think).

sfuo 111 Practically a Master Poster

You need to store them as characters because you cannot have an integer hold a 50 digit number. And if you try to use a float or double you will lose precision.

So store them as a character and come up with function that does math between 2 strings.

sfuo 111 Practically a Master Poster

I fixed up your if statement at the bottom so if you do not type in y or Y it will end.

#include <iostream>

using namespace std;

int main()
{
	cout << "\n\t\tWelcome to Doc's gas figure out thingy!\n";

	Car car;

	bool another = true;
	while(another)
	{
		Car next;
		next.drive();

		cout << "\n\n\n\t\t\tHere are your results ";
		next.print_result();

		cout << "\n\n\t\t\tAnother Car? (y/n): ";
		string response;
		getline(cin, response);
		if ( response != "y" && response != "Y" )
			another = false;

	}


	return 0;
}