sfuo 111 Practically a Master Poster

What he means is that the 3ds file is just loaded up with all the geometric primitives of the object then imported into C++ and drawn with OpenGL/DirectX.

I really doubt that a "pro" (someone in the business that gets paid) would sit there hardcoding the object point by point unless the object was very simple.

sfuo 111 Practically a Master Poster

Are you adding the libraries libopengl32.a and libglu32.a?

GLUT is a toolkit to try and make it easier to create OpenGL applications, so adding glu.h and gl.h would not resolve the problem with the missing header.

Plus GLUT has been discontinued so if you want to use it still you need to get freeGLUT and all you have to change is the include files (the people that made freeGLUT kept all function names the same or at least most of them).

sfuo 111 Practically a Master Poster

SDL_Surface is just a structure that holds the needed information for drawing. TTF_RenderText_Solid() will just return a pointer to a block of memory where a SDL_Surface is being stored and then you make a pointer point to the memory location of that object so then you can draw it to the screen.

TTF_RenderText_Solid() is just a function that returns a pointer to a SDL_Surface and is not derived from the SDL_Surface type (because it is a function and SDL_Surface is not a class).

sfuo 111 Practically a Master Poster

What you would need is a check for when the even is SDL_KEYUP and then set the message to 0 there rather than after the message is displayed.

void eve()
{
	while( run == true)
	{
		while( SDL_PollEvent(&event) )
		{
			if ( event.type == SDL_QUIT )
			{
				run = false;
			}

			if ( event.type == SDL_KEYDOWN )
			{
				switch( event.key.keysym.sym )
				{
				case SDLK_UP: message = Up; break;
				case SDLK_DOWN: message = Down; break;
				case SDLK_RIGHT: message = Right; break;
				case SDLK_LEFT: message = Left; break;
				}
			}
			if ( event.type == SDL_KEYUP )
			{
				switch( event.key.keysym.sym )
				{
					default: message = 0; break; //set message to 0 when key is released (this is if any key is released)
				}
			}

		}
		blit(back,screen,0,0); //always draw the background
		if ( message != 0 ) //draw the message if there is one
			blit(message,screen,100,300);
		SDL_Flip(screen);
	}
}
sfuo 111 Practically a Master Poster

I'd have to look at the source code you were running. The download-able code on his website doesn't seem to have any problems. The message flashing part makes me think that you had apply_surface( 0, 0, background, screen ); outside of the message != NULL check.

As for the freezing part I'm not sure because I'd have to look at what you had.

sfuo 111 Practically a Master Poster

He sets it to NULL (or 0) because that way he doesn't reprint the same message constantly. Whenever you press a key message becomes non-NULL and it redraws and this has nothing to do with the program quitting.

sfuo 111 Practically a Master Poster

You are going to buy something that costs $3500 and you don't know what it does? I have never worked with model files in OpenGL (yet) but it will just be all the texture coords, vertexes, normals and all the information needed to draw and move the model.

sfuo 111 Practically a Master Poster

Why don't you get the free trial, play around with it and see what you can do, then buy it.

And I'm 100% sure it exports model files (with all the vertex info) rather than images. Not sure why you would think that it exports just images.

sfuo 111 Practically a Master Poster

I think your method in general is the problem. I looked up Knight's Tour in Wikipedia and read the Wansdorff section and came up with my own code. This method is really easy to implement because I had never heard of this Knights Tour puzzle and I put this together in a few hours.

The only thing that might be slightly advanced and you have not seen is a structure and its operators but the whole point they were put in was because it is easier to think in objects (a position has an x and y value and then the operators just allow you to add them together).

Here is what I came up with and it is loosely based off yours.

#include <iostream>
#include <ctime>
#include <cstdlib> //used for CLS and PAUSE
#include <cstring>

using namespace std;

//board size
#define XDIM 8
#define YDIM 8

struct position
{
	int _x, _y; //data
	position(int x = 0, int y = 0) //constructor (default values of 0, 0)
	{
		_x = x;
		_y = y;
	}
	position operator +(position rhs) //allows the use of the + operator with position structures
	{
		return position(_x+rhs._x, _y+rhs._y);
	}
	void operator += (position rhs) //allows the use of the += operator with position structures
	{
		_x += rhs._x;
		_y += rhs._y;
	}
};

bool Move(bool[][YDIM], position&);
void PrintBoard(bool[][YDIM], position);
int GetNextMove(bool[][YDIM], position);
int GetNumMoves(bool[][YDIM], position, bool = false);
int GetFewestMoves(int[8]);

position moves[] = {position(-2, 1), position(-1, 2), position(1, 2), …
sfuo 111 Practically a Master Poster

You needed to think this through a little bit more before trying to put all the situations of the program in together.

You need to make the program based off the words used in the assignment text. When it says minimum payment of $2 you should start the fee at $2 and then it says additional hours after are $0.50 each so you would figure out how many additional hours they stayed and add $0.50 for each hour/partial hour.

This is the "fixed up" version of your code

#include<iostream>
using namespace std;

int main()
{
	float floatHour = 0;
	float floatFees = 0;
	int carryOver = 0, intHour = 0;

	cout<<"Enter number of hours parked: ";
	cin>>floatHour;

	//if (floatHour <= 3) //this goes because the minimum is $2 no matter what
	floatFees += 2.00; //you can use the += operator for things like this

	if (floatHour > 3) //if you want all of these lines to be part of the if() you need to put them in braces (this isnt python because indentation doesnt matter)
	{
		floatHour -= 3; //subtract the three hours to get the amount of extra time they parked for
		carryOver = floatHour  * 100;
		carryOver = carryOver % 100;
		intHour = floatHour; //there is no point in multiplying by 100 then dividing by 100 as VernonDozier said

		//the only time this applies when the time is more than 3 hours so no point in doing pointless checking
		if (carryOver == 0)
			floatFees = …
sfuo 111 Practically a Master Poster

If you look at my post I gave you the answer.

The statement random !0 should give you an error. What you need is random != 0. Same thing goes for random !1.

sfuo 111 Practically a Master Poster

He is lucky that this works. The reason it does is because when you declare an array the last element is automatically set to NULL (which is 0). Then you use getline() which extracts n-1 characters and adds a NULL at index n. So now you have two NULL characters in a row. Then you come to the while loop that checks element 50 (which is NULL) and that is less than 100 and then you increment the 50'th element by one each time. If you did not use getline() then you would have junk being printed out after the name you entered if the name was as long as the array was. This is because you are overwriting the original NULL character that the array created when the array is being made.

The "proper" (because there are many ways to do this) way of doing this is to use a for() loop that uses an integer to count to 100.

#include <iostream>
#include <string>

using namespace std;

int main ()
{
	char name[50];

	cout << "Insert Name" << '\n';
	cin.getline(name, 50);

	for( int i = 0; i < 100; i++ )
	{
		cout << name << '\n';
	}

	return 0;
}

I would really not recommend doing what you did because you might not be running into problems with it now, but something will happen if you do not use getline() or if you use getline() with an extraction size of your arraysize + 1.

sfuo 111 Practically a Master Poster

You put

cout << name << endl;

inside your loop.

I would recommend that you go through that tutorial that I linked you and you try to figure out what is going on.

sfuo 111 Practically a Master Poster

What you are looking for is a for() loop

Take a look here at control statements (including the for() loop) here.

sfuo 111 Practically a Master Poster

You would have to have your while() as

while(random != 0 || random != 1);

but this wouldnt work as you want it to. You need to use and (&&)

while(random != 0 && random != 1);
sfuo 111 Practically a Master Poster

That is because structures and functions are completely different.

Structures are blocks of data that are made up of primitive data types (int, char, float) or other structures and you cannot set default values to them within the structure. However you can make a function to set the values or directly modify them.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct
{
	int P;
}poclick;

void poclickInit(poclick *in)
{
	in->P = rand();
}

int main()
{
	poclick A;

	A.P = 0; //directly modifying the value
	printf("%d\n", A.P);

	poclickInit(&A); //using function to modify the value
	printf("%d\n", A.P);

	return 0;
}
sfuo 111 Practically a Master Poster

For a 2D game you should look into quadtrees (octrees for 3D games). What this does is it helps you manage how many objects you are checking collision against or drawing on each collision check and draw.

Since you have 50 platforms in level 1 and every time the scene recalculates you have to check against all those objects to see if you are touching them. What you should do is divide those 50 platforms into 4 nodes. Then divide each node into another 4 trees until you are down to a reasonable amount of objects in each node. When you load in your level you will do a one time check to set all the platforms into these nodes and then you do not need to move them around again.

On each recalculation of the scene you will check your stick man's box against each node and then you only need to check collision/draw the objects that might be being touched/displayed.

I made a tile game that did not use "sectors" and it lagged because it had to constantly check against hundreds of tiles on each recalculation. Then I modified the game to use sectors so it was only checking against a few tiles each time.

sfuo 111 Practically a Master Poster

You cannot use platClip[j].w directly because that is not what it is called.

You have declared levelOnePlatform in the global scope and it is usable by everything.

So if you want to access platClip[j].w you need to put it in a loop so you can iterate through each element and use the name levelOnePlatform because that is what the name of the variable in the global scope is.

If I were you I would place the clips for the player within the stick class and the clips for the platform in the platform class. This way it is more like an object because those attributes belong to that class.

sfuo 111 Practically a Master Poster

I can't really tell what you are trying to do since the code on google docs is really old (still has errors from last post).

Is this along the lines of what you are trying to accomplish?

struct SDL_Rect //I made this because I didn't want to include all the SDL stuff
{
	int x, y, w, h;
};

class Platform
{
	int numClips;
	SDL_Rect *clips;

	public:
	Platform()
	{
		numClips = 50; //so you can know how many clips you have externally rather than hardcoding all throughout your game
		clips = new SDL_Rect[numClips]; //create 50 clips
	}

	SDL_Rect *getClips()
	{
		return clips; //returns pointer to the first clip
	}

	int getNumClips()
	{
		return numClips;
	}

	~Platform()
	{
		delete clips;
		clips = 0;
	}
};

bool check_collision(Platform B)
{
	int leftB;
	for( int i = 0; i < B.getNumClips(); i++ )
	{
		leftB = B.getClips()[i].x;
	}

	return true;
}


int main()
{
	Platform A;
	check_collision(A);

    return 0;
}
sfuo 111 Practically a Master Poster

You can use a virtual function to print the info for that specific class type.

#include <iostream>
#include <list>

using namespace std;

class Book
{
	public:
	Book(){};
	Book(string t, string i)
	{
		title = t;
		ISBN = i;
	}

	virtual void PrintInfo()
	{
		cout << "Title: " << title << endl << "ISBN: " << ISBN << endl << endl;
	}

	protected:
	string title, ISBN;
};

class Publication: public Book
{
	public:
	Publication(){};
	Publication( string t, string i, string p )
	{
		title = t;
		ISBN = i;
		publisher = p;
	}

	void PrintInfo()
	{
		cout << "Title: " << title << endl << "ISBN: " << ISBN << endl << "Publisher: " << publisher << endl << endl;
	}

	protected:
	string publisher;

};


int main()
{
	list<Book*> books;

	Publication *tmpPublication = new Publication("How to Get Published", "123456789", "McGoodBooks");
	books.push_back(tmpPublication);
	Book *tmpBook = new Book("The Big Book", "987654321");
	books.push_back(tmpBook);

	//print book info
	for( list<Book*>::iterator i = books.begin(); i != books.end(); i++ )
	{
		(*i)->PrintInfo();
	}

	//delete all books from memory
	while( books.size() != 0 )
	{
		delete books.back();
		books.pop_back();
	}


    return 0;
}
sfuo 111 Practically a Master Poster

If you want us to try to compile your code then you should post it in code tags in here because most of the formatting is lost when I try to copy paste it from the rtf file.

The big thing that I see, and I'm not sure if its the only problem since I have no images and I don't really wanna re-tab all your code each time you post, is that you have SDL_Rect levelOnePlatform[1]; when you should have it with a size of 50 since that is what you are passing into it when you try clipping it.

sfuo 111 Practically a Master Poster

The problem is in the constructor. You are declaring three new integers (x, y and frame). After the constructor is done those three do not exist and stick::x, stick::y, stick::frame are not modified at all. So what you need to do is remove int from in front of

x = 0;
y = 0;
frame = 0;

so that it modifies the stick's variables.

If you cant get your debugger working then just enable the console window and use cout. Or if you are using visual studio and for whatever reason the console window doesn't wanna show up, you can use fstream and write to a file. Because I ran your code with outputs and saw that x and y were huge values which normally means that they are uninitialized.

sfuo 111 Practically a Master Poster

Here is a method using recursion that you could use.

If you would want this to work with rocket mania then you would need to do checking to see if the two pipes line up rather than just replacing the character like the function does below.

#include <iostream>
#include <cstdlib> //remove this if you are not using windows/dont want time delay redraw
#include <cstring>
#include <ctime> //remove this if you are not using windows/dont want time delay redraw

using namespace std;

void Print(char[][5]);

size_t resetTime = clock(); //remove this if you are not using windows/dont want time delay redraw

void Search(int x, int y, char board[][5])
{
	if(board[x][y] != 'o')
		return;
	board[x][y] = '*';
	Print(board); //remove this if you are not using windows/dont want time delay redraw
	if( x > 0 )
		Search(x-1, y, board);
	if( y > 0 )
		Search(x, y-1, board);
	if( x < 4 )
		Search(x+1, y, board);
	if( y < 4 )
		Search(x, y+1, board);
}

void Print(char board[][5])
{
	while( clock() - resetTime < 500 ){}; //remove this if you are not using windows/dont want time delay redraw
	resetTime = clock(); //remove this if you are not using windows/dont want time delay redraw
	system("CLS"); //remove this if you are not using windows/dont want time delay redraw
	for( int i = 0; i < 5; i++ )
	{
		for( int c = 0; c < 5; c++ )
			cout << board[c][i] << " ";
		cout << endl;
	}
	cout << endl << endl;
}

int …
daniel955 commented: appreciated the help. +2
sfuo 111 Practically a Master Poster

You have many errors in your code, the loop ending is just one of them.

In order for the loop to end the way it is right now the person has to enter numbers out of range. A while loop will go for as long as the condition is met. In this case the condition is when the user puts in valid numbers (so change the condition in the loop to catch bad input).

You are passing variables into inputAndValidate() by value and returning nothing, this means that this function does nothing. To fix this pass values in by reference inputAndValidate(int&, int&, int&) similar to what you have already for other functions that also do nothing.

Both functions convertToMinutes() and convertBackToTime() pass values by reference but do not modify them at all. These functions make variables, return nothing and do nothing.

The calcCharge() function does not need to pass any values by reference and you do not need to pass the variable charge into it since you are returning a double.

I would recommend commenting out each function in main() and getting them to work as intended one by one, then getting them to work together.

sfuo 111 Practically a Master Poster

Your Load_image() function is always gonna return 0.

On line 13 of what you posted above delete SDL_Surface* because it is making a new variable with the same name as you have out of the if() statement and is not changing the value outside of the if().

sfuo 111 Practically a Master Poster

Not 100% sure how to explain how it holds all the memory but I think this is what you are aiming for.

When I compiled your code I was getting warning and it crashed on run-time.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char *dic[][40] = { {"Atlas", "A volume of maps"}, {"Car", "A motorized vehicle"} };

	int i;
    for( i = 0; i < 2; i++ )
    {
    	printf("%s - %s\n", dic[i][0], dic[i][1]);
    }

    return 0;
}
sfuo 111 Practically a Master Poster

Don't you have the x y z position and x y z rotation of your character (and gun)? Then just apply these to the camera with the offset so it is looking from the right height. That is if this is for a FPS.

sfuo 111 Practically a Master Poster

This is the first Linked List I have ever written but is this what you are trying to do?

The Change() function searches the list for an entry with the same name and then asks to change the age of the person.

#include <iostream>
using namespace std;

struct Node
{
	Node(){};
	Node( string n, int a )
	{
		name = n;
		age = a;
		next = NULL;
	}
	string name;
	int age;
	Node *next;
};

class List
{
	Node *first;

	public:

	List()
	{
		first = NULL;
	}

	void Add(string name, int age) //adds a new entry to the list
	{
		Node *newNode = new Node(name, age);
		Node *curNode = first;


		if( curNode == NULL )
		{
			first = newNode;
			return;
		}

		while(curNode->next != NULL)
		{
			curNode = curNode->next;
		}
		curNode->next = newNode;
	}

	void Change(string name) //finds and changes the 
	{
		Node *curNode = first;
		bool found = false;

		if( curNode == NULL )
			return;

		if( curNode->name == name )
			found = true;

		while(curNode->next != NULL || found != true)
		{
			curNode = curNode->next;
			if( curNode->name == name )
				found = true;
		}

		if( found == false )
			return;

		cout << "What would you like " << curNode->name << "'s new age to be? (currently " << curNode->age << ")" << endl;
		cin >> curNode->age;
		cout << endl;

	}

	void Print() //displays contents of the list
	{
		Node *curNode = first;

		if( curNode == NULL )
			return;
		cout << curNode->name << " " << curNode->age << endl;
		while(curNode->next …
sfuo 111 Practically a Master Poster

I would really suggest not using C and C++ the way you are. You have outputs using cout and printf().

Here is a C++ convert.

#include <iostream>
#include <fstream>

using namespace std;

struct patient
{
	string name;
	string blood;
	string height;
	string Ssn;
};

	bool I_code3(string name, patient &ab); //Function for search logic
	//void search_C_Interface();
	//void menu();
	void saved(patient ab);

void sI_name()
{
	patient ac;    //structure patient
	string name;  //char for user input

	cout << " -----Search by Name------- " << endl;
	cout << " Name for Search: ";
	cin >> name;

	if(I_code3(name, ac) == true)   //If the data is found display:
	{
		cout << "\n\n name: " << ac.name << endl;
		cout << " Blood: " << ac.blood << endl;
		cout << "Height: " << ac.height << endl;
		cout << "Social Security: " << ac.Ssn << endl << endl;
	}

	else
	{   //if its not output:
		cout << endl << " Not found " << endl;
	}
	cout << "    1.Search for Another Patient" << endl;  //other functionalities
	cout << "    2.Search with another method" << endl;
	cout << "    3.Return to main screen" << endl;
}

bool I_code3( string name, patient &ab) //logic for searching
{
	ifstream f("saved.txt");  //saved is the name of my .txt file

	while( f >> ab.name >> ab.blood >> ab.height >> ab.Ssn )
	{
		if( ab.name.find(name) != string::npos )
		{
			f.close();
			return true;
		}
	}

	f.close();
	return false;
}

int main()
{
	sI_name();

	return 0;
}
sfuo 111 Practically a Master Poster

You have more problems than just lines 5,6, 7.

To fix lines 5, 6, 7 make them pointers and then use calloc() to allocate blocks of memory for them after figuring out how many students you are gonna have input for.

You were putting ';' at the end of the loops. This is legal but nothing happens. Remove them and it will actually loop rather than run once.

#include <stdio.h>
#include <stdlib.h>
int main (void)
{
    int A = 0 , B = 0, C = 0, D = 0, E = 0, F = 0;
    int *id1;
    float *grade;
    float average;
    int kk;
    int num1;
/********* Jami, Abdulrahman *********/
    printf("Enter The Number of students: ");
    scanf("%d", &num1);

	//sets the size of the arrays
    id1 = (int*)calloc(num1, sizeof(int));
    grade = (float*)calloc(num1, sizeof(float));


    for (kk = 0; kk < num1; kk++)
    {
    	printf("Enter The Student ID: ");
        scanf("%d", &id1[kk]);
        printf("Enter The Student's grade: ");
        scanf("%f", &grade[kk]);
        printf("\n");
    }

    for (kk=0; kk<num1; kk++)
    {
        if (grade [kk]>85 && grade [kk]<=100)
			A=A+1;

        if (grade [kk]>70 && grade [kk]<85)
			B=B+1;

        if (grade [kk]>55 && grade [kk]<70)
			C=C+1;

        if (grade [kk]>40 && grade [kk]<55)
			D=D+1;

        if (grade [kk]>25 && grade [kk]<40)
			E=E+1;

        if (grade [kk]>=0 && grade [kk]<25)
			F=F+1;
    }
/********* Jami, Abdulrahman *********/
	float sum = 0;
	for( kk = 0; kk < num1; kk++ )
	    sum = sum + grade[kk];
    average = sum / num1-1;
    printf("The Average is %f%%\n", average);
    printf("There are:\n");
    printf("%d - As\n%d - Bs\n%d - Cs\n%d - Ds\n%d …
sfuo 111 Practically a Master Poster

Would look more like a circle if the characters were square and line spacing was the same as character spacing.

#include <iostream>
using namespace std;

int main()
{
	double r = 1.2;

	for( double y = -r-0.1; y <= r+0.2; y += 0.1 )
	{
		for( double x = -r-0.1; x <= r+0.2; x += 0.1 )
		{
			if( (x*x + y*y <= (r*r)*1.1) && (x*x + y*y >= (r*r)*0.9) )
				cout << "*";
			else
				cout << "#";
		}
		cout << endl;
	}
	return 0;
}

Output:

###########################
##########*******##########
#######****#####****#######
######**###########**######
#####**#############**#####
####*#################*####
###**#################**###
##**###################**##
##*#####################*##
##*#####################*##
#**#####################**#
#*#######################*#
#*#######################*#
#*#######################*#
#*#######################*#
#*#######################*#
#**#####################**#
##*#####################*##
##*#####################*##
##**###################**##
###**#################**###
####*#################*####
#####**#############**#####
######**###########**######
#######****#####****#######
##########*******##########
###########################
sfuo 111 Practically a Master Poster

Does your PlaySound() function also load the sound file into memory?

If it does then you should load them before then use that to just play them.

sfuo 111 Practically a Master Poster

Why don't you make your printDeck() function and not display the cards within the shuffle function? This way you will always print out each card once.

sfuo 111 Practically a Master Poster

There are a few things that you need to do.

The main ones are formatting and basic syntax. I would suggest going over the tutorial at http://www.cplusplus.com/doc/tutorial/.

// multiplication
#include <iostream> //use iostream (iostream.h should not be used any more)
using namespace std; //can use this or add std:: infront of cout and endl or you can use using std::cout; and using std::endl;

int main()
{
	int j, i, multi;

	for( j = 1; j < 13; j++ ) //get rid of semi-colon
	{
		for( i = 1; i < 13; i++ ) //get rid of semi-colon
		{
			multi = j*i;
			cout << multi << endl; //change colon to semi-colon (added << endl to make output readable)
		}
	}
	return 0;
}
sfuo 111 Practically a Master Poster

On line 123 make it a friend function.

inline friend Vector3 operator *(float k, const Vector3 &v)

This won't work if you have your class defined within main() but I'm not too sure why you have it like that in the first place.

sfuo 111 Practically a Master Poster

There are lots of ways to fix up your code, depending on if you want to pass by reference or just return a vector and copy it.

This is creating a vector in function1() and returning it.

#include <iostream>
#include <vector>
#include <string>

using namespace std;


vector<string> function1()
{
	vector<string> v(4);
	for( unsigned int i = 0; i < v.size(); i++ )
		cin >> v[i];
	return v;
}

int main ()
{
	vector<string> guess(4);
	guess = function1();
	cout << "size:" << guess.size() << endl;
	cout << "contents:";

	for( unsigned int i = 0; i < guess.size(); i++ )
		cout << guess[i] << "";
	cout << endl;
	return 0;
}

This is using pass by reference to populate the vector guess.

#include <iostream>
#include <vector>
#include <string>

using namespace std;


void function1(vector<string> &v)
{
	for( unsigned int i = 0; i < v.size(); i++ )
		cin >> v[i];
}

int main ()
{
	vector<string> guess(4);
	function1(guess);
	cout << "size:" << guess.size() << endl;
	cout << "contents:";

	for( unsigned int i = 0; i < guess.size(); i++ )
		cout << guess[i] << "";
	cout << endl;
	return 0;
}

They both give the same result but as a beginner I would suggest sticking with option #1.

As for your code the main issues were that you were redefining a variable on lines 20 and 21, and you were redefining vector v when passing it into function1().

Compare your code to my first example and you will see …

sfuo 111 Practically a Master Poster

Not sure if you have figured this out yet or not.

The problem is because you are calling the function SDL_DisplayFormat() before SDL_Init(SDL_INIT_EVERYTHING) .

The fix to this would be to move load_files() below SDL_Init(SDL_INIT_EVERYTHING) .

sfuo 111 Practically a Master Poster

Walt why are you so hostile all the time? I could sit here all day calling people stupid because some of them have no clue what they are doing.

If you think they are retarded don't reply to the post.

WaltP commented: When you get another 6000 posts and 3 additional years, let's see where you are. -4
sfuo 111 Practically a Master Poster

Your code will not enter the inner for() loop because you have c = 0 right before it and your condition is when c > 0 .

sfuo 111 Practically a Master Poster

You are using sleep() functions that make the program sleep for 13 hrs 53 min and a few seconds.

What I would suggest is using the clock() function to get the time elapsed since the start of the program in milliseconds.

Here is something that I put together using your code as a base.

#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <time.h>
using namespace std;

#define MS_IN_HR	3600000
#define MS_IN_MIN	60000
#define MS_IN_SEC	1000


int main()
{

	 int m,s,h,ms;
	 time_t totalMS = 0, timeLeft;

	 cout << "A COUNTDOWN TIMER" << endl;
	 cout << "enter time in hours here" << endl;
	 cin >> h;
	 totalMS += h*MS_IN_HR;
	 cout << "enter time in minutes here " << endl;
	 cin >> m;
	 totalMS += m*MS_IN_MIN;
	 cout << "enter time in seconds here" << endl;
	 cin >> s;
	 totalMS += s*MS_IN_SEC;
	 cout << "enter time in milliseconds here" << endl;
	 cin >> ms;
	 totalMS += ms;

	 system("PAUSE"); //people will hate you for using PAUSE but you are already using CLS
	totalMS += clock();

	 cout << " A COUNTDOWN TIMER" << endl;
	 cout << "time remaining" << endl;
	 cout << "hours: " << h << "mins: " << m << " secs: " << s << " milli: " << ms << endl;

	 while(clock() < totalMS)
	 {
	 	timeLeft = totalMS - clock();
	 	system("cls");
		cout << timeLeft/MS_IN_HR << " :hours " << (timeLeft%MS_IN_HR)/MS_IN_MIN << " :mins " << ((timeLeft%MS_IN_HR)%MS_IN_MIN)/MS_IN_SEC << " :secs "  << (((timeLeft%MS_IN_HR)%MS_IN_MIN)%MS_IN_SEC) << " :milli" << endl;
	 }
	 system("cls");
	 cout …
sfuo 111 Practically a Master Poster

If you scroll to the bottom of that website you linked you will see unsetf().

Here is an example

#include <iostream>
using namespace std;

int main()
{
	cout.setf(ios_base::fixed);
	cout << 100.1 << endl; //with fixed
	cout.unsetf(ios_base::fixed);
	cout << 100.2 << endl; //without fixed

	return 0;
}
sfuo 111 Practically a Master Poster

Pretty sure what you just posted is trying to get the size of the window that was made by the running program. You haven't made a window so it is going to be 0 by 0 in size.

I can't compile what you have but I just threw in the lines of code I use for getting the fullscreen window size.

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

int CDECL MessageBoxPrintf (TCHAR * szCaption, TCHAR * szFormat, ...)
{
	TCHAR szBuffer [1024];
	va_list pArgList;
	va_start (pArgList, szFormat);
	_vsntprintf_s (szBuffer, sizeof(szBuffer) / sizeof(TCHAR),
		szFormat, pArgList);
	va_end(pArgList);
	return MessageBox (NULL, szBuffer, szCaption, 0);

}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	int cxScreen, cyScreen;

	//handles for desktop
	HWND hDesktopWnd;
	HDC hDesktopDC;

	hDesktopWnd = GetDesktopWindow();
	hDesktopDC = GetDC(hDesktopWnd);

	cxScreen = GetDeviceCaps(hDesktopDC, HORZRES);
	cyScreen = GetDeviceCaps(hDesktopDC, VERTRES);

	ReleaseDC( hDesktopWnd, hDesktopDC );

	MessageBoxPrintf (TEXT ("Screen Resolution"),
			  TEXT ("The screen is %i pixels by %i pixels high."
			  ,cxScren, cyScreen));
	return 0;
}
sfuo 111 Practically a Master Poster

If you want to use arguments then you need to use main() with argc and **argv.

argc is the counter of how many arguments that are passed in to the program (it is 1 with no additional arguments passed because it passes it's own path by default).

argv is the "vector" that holds all the arguments passed.

In Windows to pass arguments you need to run the command line and type "start FILEPATH arg1 arg2". Or you can use "call" if you want to keep it in the existing window.

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main(int argc, char **argv)
{
	int i;
	for( i = 1; i < argc; i++ )
		printf("%s\n", argv[i]);

	printf("Press any key to continue...");
	getch();
	return 0;
}

If you want the argument to be converted to an integer then you can use the atoi() function.

sfuo 111 Practically a Master Poster

Here is how you could initialize and draw the board.

TicTacToe::TicTacToe()
{
	player = 'O';
	for( int i = 0; i < 9; i++ )
		board[i] = i+'1';
}

void TicTacToe::displayBoard()
{
	// Your implementation here...
	for (int i = 0; i < 9; i++)
		if( (i+1) % 3 == 0 )
			cout << board[i] << endl;
		else
			cout << board[i] << " | ";
}

You will need to add the prototype TicTacToe(); within the class also.


There are many other things with this program that are either useless or will not work as intended.

In main() you use a for() loop to run the game but if I were to enter something invalid 9 times in a row the game would end since it runs exactly 9 times.

One way you could fix this is by using a while() loop and having a variable called winner or something that holds values of 0, 1, 2 or 3 (0 means no winner, 1 or 2 is the winner and 3 is draw).

Also when the player gives bad input it switches to the other players turn so you have to come up with a way to get their input again without breaking out of the function (hint: use a do/while loop).

Since you are doing error checking before placing the piece on the board you can replace all the if/else ifs with board[c-'1'] = player; and it will do the exact …

sfuo 111 Practically a Master Poster

5050 is the sum of the numbers from 1-100.

You are printing the value returned from counter in main() so it will only print once.

If you want to print all the numbers from 1-100 you should have your print statement within the recursive function and you do not need to have the function return anything (make it a void function).

chaoz014 commented: thank you... +0
sfuo 111 Practically a Master Poster

On line 36 of what you posted you have int askForPlace(); you need to remove "int".

When compiling this I got lots of warnings because you have a bunch of functions that are defined to return an int but do not return anything. If you want them to return nothing then make them void functions otherwise you have to return a value or it will give a junk value.

And your main() function should look something like this

int main()
{
    /* code */
    return 0; //always return at the end of main
}
sfuo 111 Practically a Master Poster

In WinAPI almost all structures and classes are in all caps so that might just be a convention you follow.

sfuo 111 Practically a Master Poster

If its C++ then you should post in the C++ forum.

You should also post the code that you have so far.

What you need is a float that holds the total of all the items being entered. A float to hold the amount of money the user gives. Then output the amount of money the person gave minus the total of all the items and that will give you the change.

Salem commented: Nice +17
sfuo 111 Practically a Master Poster

In C++ I'd use classes and their operators to add the fractions together.

You can play around with overloading the >> and << operators to make calling input/output neater.

#include <iostream>
#include <conio.h>
using namespace std;

class FRACTION
{
	int numerator;
	int denominator;

	public:

	FRACTION()
	{
		cin >> numerator >> denominator;
	}
	FRACTION(int num, int denom)
	{
		numerator = num;
		denominator = denom;
	}

	int GetNumerator()
	{
		return numerator;
	}

	int GetDenominator()
	{
		return denominator;
	}

	friend void operator+=(FRACTION &lhs, FRACTION rhs)
	{
		lhs.numerator = lhs.numerator*rhs.denominator + rhs.numerator*lhs.denominator;
		lhs.denominator *= rhs.denominator;
	}

	friend FRACTION operator+(FRACTION lhs, FRACTION rhs)
	{
		return FRACTION(lhs.numerator*rhs.denominator + rhs.numerator*lhs.denominator, rhs.denominator*lhs.denominator);
	}

};

int main()
{

	cout << "Enter fraction numbers ";
	//using += operator
	FRACTION first, second;
	first += second;

	cout << first.GetNumerator() << "/" <<  first.GetDenominator() << endl;

	cout << "Enter fraction numbers ";
	//using + operator
	FRACTION third, fourth, result(0,0);
	result = third + fourth;

	cout << result.GetNumerator() << "/" <<  result.GetDenominator() << endl;

	getch();
	return 0;
}
sfuo 111 Practically a Master Poster

You cannot return multiple values at once unless they are bound within a structure or an array (even then you are just returning the place in member where they start). There are two ways that you can do this (there are more):
1) Pass values by reference and modify one set as your answer
2) Create a structure and return the value in it

Below is code I put together based off yours but using a structure for the fractions.

#include <stdio.h>
#include <conio.h>

typedef struct
{
	int numerator;
	int denominator;
}FRACTION;

FRACTION frac(FRACTION, FRACTION);

int main()
{
	FRACTION first, second, result;
	printf("Enter fraction numbers ");
	scanf("%d%d%d%d",&first.numerator,&first.denominator,&second.numerator,&second.denominator);
	result = frac(first, second);

	printf("%d/%d", result.numerator, result.denominator);

	getch();
	return 0;
}

FRACTION frac(FRACTION a, FRACTION b)
{
	a.numerator = (a.numerator*b.denominator + b.numerator*a.denominator);
	a.denominator = a.denominator*b.denominator;
	return a;
}

EDIT: I thought this was for C since you are using C headers. Rewriting this in C++.