sfuo 111 Practically a Master Poster

Quote originally posted by sfuo ...

Good to know. It works with MinGW in Code::Blocks.

Maybe so. But 3 years from now when you move to a new compiler and the code you've been using for the past 7 years suddenly doesn't work anymore, are you going to remember it might be because if fflush()? What's the chance your reaction will be "but it's always worked before!"

Stop using it now and get a jump on good habits.

I meant good to know not to use it.

When I was looking for something to clear the input stream I came across fflush() on http://www.cplusplus.com/reference/clibrary/cstdio/fflush/ and just tested it rather than reading what they had written about the function.

sfuo 111 Practically a Master Poster

Replace line 23 with getchar(); because I learned that it is bad practice to use fflush(stdin); since it has undefined behavior with input streams and will only work on some compilers.

sfuo 111 Practically a Master Poster

Good to know. It works with MinGW in Code::Blocks.

sfuo 111 Practically a Master Poster

Here is a rough example of why you would want to use it.

If you comment out fflush(stdin); then it skips asking for input every second one, but with it you get asked every time.

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

int main()
{
	int i = 1;
	char input;
	while(1)
	{
		printf("\n\nLoop number %d - input 'Y' or 'y' to stop\n", i);
		fflush(stdin);
		scanf("%c", &input);
		if( input == 'y' || input == 'Y' )
			break;
		i++;
	}

	return 0;
}
WaltP commented: Flushing stdin is undefined. Do NOT do it. -4
sfuo 111 Practically a Master Poster

If you want to be able to alter the output you have to use variables not hardcode in the letters.

For this I used a string of characters alpha and placed them into the output.

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

int main()
{
	char cMarker1;
	int i = 1;
	char alpha[] = "abcdefghijklmnopqrstuvwxyzW";
	while(1)
	{
		printf("****************  TURN %d  ******************\n\n", i);
		printf("    |     |        |     |        |     |     \n");
		printf("  %c |  %c  | %c    %c |  %c  | %c    %c |  %c  | %c   \n", alpha[0], alpha[1], alpha[2], alpha[9], alpha[10], alpha[11], alpha[17], alpha[18], alpha[19]);
		printf(" ___| ___ |___  ___| ___ |___  ___| ___ |___  \n");
		printf("    |     |        |     |        |     |     \n");
		printf("  %c |  %c  | %c    %c |  %c  | %c    %c |  %c  | %c   \n", alpha[3], alpha[4], alpha[5], alpha[12], alpha[26], alpha[13], alpha[20], alpha[21], alpha[22]);
		printf(" ___| ___ |___  ___| ___ |___  ___| ___ |___  \n");
		printf("    |     |        |     |        |     |     \n");
		printf("  %c |  %c  | %c    %c |  %c  | %c    %c |  %c  | %c   \n", alpha[6], alpha[7], alpha[8], alpha[14], alpha[15], alpha[16], alpha[23], alpha[24], alpha[25]);
		printf("    |     |        |     |        |     |     \n\n");

		printf("Where would you want to place your \nmarker? ");
		fflush(stdin);
		scanf("%c", &cMarker1);

		if( cMarker1 >= 'a' && cMarker1 <= 'z' )
		{
			alpha[cMarker1-'a'] = 'X';

			printf("You chose to place your marker on \nblock %c\n", cMarker1);
		}
		else if( cMarker1 == 'W' )
		{
			alpha[26] = 'X';

			printf("You chose to place your marker on \nblock %c\n", cMarker1);
		}
		else
			printf("Cannot place your marker at %c\n", cMarker1);
		printf("********************************************\n");

		i++;
	}

	return 0;
}
sfuo 111 Practically a Master Poster

Looks fine to me. Use floats or doubles instead of integers since ints do not hold decimal places.

sfuo 111 Practically a Master Poster

I actually started with C++ so I learned from http://www.cplusplus.com/doc/tutorial/ but learning loops, variables and arrays is common between the two of them.

sfuo 111 Practically a Master Poster

If you wanna store the names like a = ant you should use strings (char*).

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

#define sz 12

int main()
{
	int i, j;
	char* animals[sz] = {"ant", "bear", "cat", "dog", "emu", "goat", "lizard", "monkey", "parrot", "rabbit", "snake", "tiger"};
	char* chosen[4] = {"", "", "", ""};
	srand(time(NULL));

	for( i = 0; i < 4; i++ )
	{
		chosen[i] = animals[rand()%12];
		for( j = 0; j < 4; j++ )
			if( strcmp(chosen[i], chosen[j]) == 0 && j != i ) //checks to see if the animal picked is unique
			{
				i--; //if not decrease counter so it overwrites the last animal
				break;
			}
	}

	for( i = 0; i < 4; i++ )
	{
		printf("%c - ", chosen[i][0]); //for first letter of animals name
		printf("%s  ", chosen[i]); //for whole name of animal
	}
	printf("\n");


	return 0;
}
ineedsomehelp:3 commented: Very informative :) +0
sfuo 111 Practically a Master Poster

After fixing a bunch of typos and added to the bottom of Advanced2D.cpp (you have the extern prototypes but you do not actually make the functions)

bool game_init(HWND in)
{
	return true;
}
void game_update()
{

}
void game_end()
{

}

bool game_preload()
{
	return true;
}

Make sure you include the libraries
d3dx9.lib
d3d9.lib
winmm.lib

And you really need to work on formatting the code since it was really difficult to figure out where the problems were.

Sudo Bash commented: good for you, reading all that code. +1
sfuo 111 Practically a Master Poster

This is the C forum so this is how you could do it in C

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

int main()
{
	int i;
	for( i = 0; i < 256; i++ )
		printf("%c",i);
	return 0;
}

For C++ you could do this

#include <iostream>
using namespace std;

int main()
{
	for( int i = 0; i < 256; i++ )
		cout << char(i);

	return 0;
}

If you really need an explanation then maybe you should go look at http://www.asciitable.com/ since its pretty straight forward.

sfuo 111 Practically a Master Poster

You can try to use a math function like y=2^(x/3) set your x and y coordinates for the ramp (it would look like this).

The function looks like a ramp and depending on the increment for x you can make it more or less smooth and you can change the length of the ramp by setting the upper bound of the for() loop used to make the ramp.

sfuo 111 Practically a Master Poster

Why cant you use something like this? The only variables in the formula are 'k' and how many times it loops, not sure why you ask for input when the number 4 is constant.

#include <iostream>
#include <cmath>

using namespace std;

double approachPi()
{
	double sum = 0;
	int size = 1000;
	for( int k = 1; k < size; k++ )
		sum += pow(-1,(k+1))/((2*k)-1);

	return 4*sum; //return the sum of the series * 4
}

int main()
{
	cout << approachPi() << endl;
	return 0;
}
sfuo 111 Practically a Master Poster

You can do it with a bunch of if/else statements like this

#include <iostream>
using namespace std;

int main()
{
	string encoded = "45323456", decoded = "", encodedPart;

	for( unsigned int i = 0; i < encoded.length(); i+=2 )
	{
		encodedPart = encoded.substr(i, 2);
		if( encodedPart == "45" )
			decoded += 'd';
		else if( encodedPart == "32" )
			decoded += 'o';
		else if( encodedPart == "34" )
			decoded += 'v';
		else if( encodedPart == "56" )
			decoded += 'e';
		else
			; //this does nothing but without it you will get an error since there is nothing
	}

	cout << decoded << endl;

	return 0;
}

I wouldn't really say the map is over your head since just an array but with custom indexes (some languages call them dictionaries because that is pretty much how they are used).

In map<string, char> the index is a string and what gets held at that index is a char.

Its almost exactly the same as if you had an array of characters except for it is indexed by a string and it is a dynamic array rather than a static one.

sfuo 111 Practically a Master Poster

You could use a map to help decode the message.

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

int main()
{
	map<string, char> cipher;
	cipher["45"] = 'd';
	cipher["32"] = 'o';
	cipher["34"] = 'v';
	cipher["56"] = 'e';

	string encoded = "45323456", decoded = "";

	for( unsigned int i = 0; i < encoded.length(); i+=2 )
		decoded += cipher[encoded.substr(i, 2)];

	cout << decoded << endl;

	return 0;
}
sfuo 111 Practically a Master Poster

You make a new thread, show your code and tell us some of the problems you have.

sfuo 111 Practically a Master Poster

You need to include the <cstring> header

sfuo 111 Practically a Master Poster

Lets see some of your code. Then we will know what areas to help you with.

sfuo 111 Practically a Master Poster

Another method would be to use a stringstream.

#include <sstream> //need these headers
#include <algorithm>

int reverseDigit2( int number )
{
	string convert = "";
	stringstream strm;
	strm << number;
	strm >> convert;
	reverse(convert.begin(), convert.end());

	return atoi(convert.c_str());
}
sfuo 111 Practically a Master Poster

I changed your reverseDigit() function so it will actually store the answer to a digit using / and % like you have.

The reason why you get an extra 1 at the end of the output when you keep return b is because you have it printing out in the function then returning the final value of b which is 1 in the case of 12345.

When you remove return b it still prints out 5 4 3 2 1 because of your print statements within the function but then it outputs a garbage number when you are printing the return value of the function. (it is garbage because you aren't returning anything)

You have two options.

Use the code that I posted below or change cout << reverseDigit(12345) << endl; to reverseDigit(12345); (remove the print statements)

#include <iostream>
#include <conio.h>
#include <cmath>

using namespace std;

int reverseDigit( int number );

int main()
{
	int inpt;
	cout << "ENTER ANY INTEGER IT WILL REVERSE THE INTEGER AND PRINT IT." << endl;
	cin >> inpt;
	cout << "The reverse integer is = ";
	cout << reverseDigit(inpt) << endl;

	return 0;
}

int reverseDigit( int number )
{
	int b = 0;
	int i = 0, n;

	for( i = -1, n = number; n > 0; i++ )
		n /= 10;

	while( number > 0 )
	{
		b += (number%10)*pow(10,i);
		number = number/10;
		i--;
	}
	return b;
}
sfuo 111 Practically a Master Poster

The integer value of ' ' is 32 so you could replace ' ' with 32 in the equation if you wanted to.

Go to http://www.asciitable.com/ and you can see the values for all the characters.

sfuo 111 Practically a Master Poster

This is just using the fact that bool(x) is 1 when x != 0 and bool(x) is 0 when x = 0.

When row is 0 you get

char(bool(0)*32 + ' ' + 0)
bool(0) = 0
anything times 0 = 0
and ' ' + 0 = ' '
so we output a ' '

Row 1 you get

char(bool(1)*32 + ' ' + 1)
bool(1) = 1
1 * 32 = 32
32 + ' ' + 1 = 65 (' ' = 32)
char(65) = 'A'

Row 2 you get

char(bool(2)*32 + ' ' + 2)
bool(2) = 1
1 * 32 = 32
32 + ' ' + 2 = 66 (' ' = 32)
char(66) = 'B'

and so on

sfuo 111 Practically a Master Poster

You should use the C++ headers rather than c headers.
If you need to use a c header like <string.h> use <cstring>.

You probably have to fix the layout since 1-9 looks fine but when you get into double digits the column numbers don't line up.

#include <iostream> //use C++ headers
#include <cstring> //needed for memset
using namespace std; //used for cout and endl

int main()
{
	int row, column;
	char cinema[20][20];
	memset(cinema, '*', 20*20); //sets the cinema array to all '*'s

	for(row = 0; row < 20 ; row++)
	{
		if( row == 7 || row == 14 ) //adds row spacers
			cout << endl;
		cout << char(bool(row)*32+' '+row) << " "; //gets rid of the char array of A B C...
		for( column = 0; column < 20; column++ )
		{
			if(column == 0 || column == 4 || column == 16)
			{
				cout << " "; //adds column spacers
			}
			if( row == 0 ) //prints numbers along the top
				cout << column+1 << " ";
			else
				cout << cinema[row][column] << " "; //prints each seat
		}
		cout << endl;
	}
	return 0;
}
sfuo 111 Practically a Master Poster

I would recommend using Code::Blocks because I find it easier to use than Visual Studio and those are the two that people should use for windows.

You can download it here (this comes with the MinGW compiler pre-installed).

To make a new C project start up Code::Blocks and then click Create New Project >> Console application >> then fill in the project title.


As for what Aia said before me, I disagree.

There is learning how to use the IDE 100% and then just enough to start doing a bit of programming. When using an IDE you have the advantage of auto completion, error checking and much more (compared to my experience with the gcc compiler that ships with linux).

sfuo 111 Practically a Master Poster

I kinda did.

Lets see what you have so far. You said you are getting errors so you must have something.

sfuo 111 Practically a Master Poster

Declare two floats - area, radius.
Take in input for radius.
area = 3.1415 * radius * radius
Output area.

If you don't know how to do input/output or even declarations then you should go read a book or something.

sfuo 111 Practically a Master Poster

Never really thought about doing it that way but that kinda seems like code that you would use and not show people that are just learning C++ since it just adds complexity to something they don't really understand in the first place.

For example when I was just starting to get into programming I saw people using a '?' with if statements and I had no clue what was going on, especially when variable names aren't 100% clear.

sfuo 111 Practically a Master Poster

You can use pretty much what firstPerson suggested but get rid of the dollar sign and commas with one function. And replace_if by itself doesn't actually delete the characters you do not want, it just moves them to the end of the string, so use erase() to trim the string and then call atof() to convert the string to a double.

#include <iostream>
#include <algorithm>

using namespace std;

bool notWanted( char in )
{
	if( in == ',' || in == '$' )
		return true;
	return false;
}

int main()
{
	string str = "$123,345,567.12";
	double val = 0;

	str.erase( remove_if(str.begin(),str.end(), notWanted), str.end() );
	val = atof(str.c_str());

	cout << fixed << val << endl; //use fixed otherwise it will output in scientific notation

	return 0;
}
sfuo 111 Practically a Master Poster

Here is something I threw together pretty quick.

This breaks down the input into separate strings of numbers and operators.

You can use atoi() (string to int) to convert the number of string type to an integer.

This is pretty basic so you will want to add to it if you want variables and other things.

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

int main()
{
	vector<string> eqnParts;
	string eqn, part = "";
	cout << "Please input your equation: ";
	getline(cin, eqn);

	for( unsigned int i = 0; i < eqn.length(); i++ )
	{
		if( eqn[i] == '+' || eqn[i] == '-' || eqn[i] == '*' || eqn[i] == '/' )
		{
			eqnParts.push_back(part);
			part = eqn[i];
			eqnParts.push_back(part);
			part = "";
		}
		else
		{
			part += eqn[i];
			if( i == eqn.length()-1 )
				eqnParts.push_back(part);
		}
	}

	for( unsigned int i = 0; i < eqnParts.size(); i++ )
		cout << eqnParts[i] << endl;

	return 0;
}
sfuo 111 Practically a Master Poster

You should really start a new thread for new questions since this is a really old thread.

To find a char in a string you can use the find() member of the string class and get the index of it.

example:

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

int main()
{
	string eqn = "x + 2 + 2 = 3";
	int pos = -1;
	char toFind = '+';
	do //this loop will find all occurrences of the char to you want to find
	{
		pos = eqn.find(toFind, pos+1);
		if( pos != -1 ) //if the char was found
			cout << toFind << " was found at " << pos << endl;
	}while( pos != -1 ); //end loop if char wasn't found

	return 0;
}
sfuo 111 Practically a Master Poster
bool is_prime(int n)
{
     for(int i = 2; i <= sqrt(n); i++) <---- use sqrt(n)
     {if(n % i == 0) return false;}
     return true;
}

The algorithm is from 2 to sqrt(n) not n/2.

sfuo 111 Practically a Master Poster

You could use two functions for drawing like this.

void RenderOverlay( GLenum mode )
{
	glViewport(0, 0, (GLsizei) WINDOW_WIDTH, (GLsizei) WINDOW_HEIGHT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	glTranslatef(0,0,0); //dont actually have to do since it is default 0
	//also have rotation at 0
	ORTHO_WIDTH = ORTHO_HEIGHT*((GLdouble)WINDOW_WIDTH/(GLdouble)WINDOW_HEIGHT);
	glOrtho(0, ORTHO_WIDTH, 0, ORTHO_HEIGHT, -1, 20);

	glMatrixMode(GL_MODELVIEW);

	glLoadIdentity();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();
		//draw your crosshair and other HUD elements
		glPushMatrix();
			glBegin(GL_QUADS);
			
			glEnd();
		glPopMatrix();
	glPopMatrix();
}

void RenderScene( GLenum mode )
{
	glViewport(0, 0, (GLsizei) WINDOW_WIDTH, (GLsizei) WINDOW_HEIGHT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();


	camera.Position();
	
	gluPerspective(60, (GLfloat) WINDOW_WIDTH/ (GLfloat) WINDOW_HEIGHT, 0.1, 60.0);

	glMatrixMode(GL_MODELVIEW);

	glLoadIdentity();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();
		//draw world objects
		glPushMatrix();
			glBegin(GL_QUADS);
			
			glEnd();
		glPopMatrix();
	glPopMatrix();
}

I doubt you can use this code directly but hopefully you can get an idea of the method I'm showing.

pcgamer2008 commented: Showed me a light...thanks !! +1
sfuo 111 Practically a Master Poster

Courier New is the font that I use in code::blocks and 'i', 'L' and '1' don't look all the same.

Note: if you type into the post editor the font is Courier New but the actual posts use a different font that has very similar characters for the 3 characters 'i', 'L' and '1'.

sfuo 111 Practically a Master Poster

Make two "layers" for your game. Have one render the 3D world (perspective) and the other for rendering the HUD (orthographic).

Only apply your camera transformations to your 3D world layer and set your camera position to 0,0,0 for the HUD layer.

sfuo 111 Practically a Master Poster

Yes with NULL passed in it.

CoInitialize(NULL);
sfuo 111 Practically a Master Poster

Hey I am running into a problem with CoCreateInstance() in a program that I am using to try to disable all the network adapters.

When I try to use

hr = CoCreateInstance(CLSID_ConnectionManager,
		NULL,
		CLSCTX_LOCAL_SERVER | CLSCTX_NO_CODE_DOWNLOAD,
		IID_INetConnectionManager,
		reinterpret_cast<LPVOID *>(&pNetConnectionManager)
		);

I get two errors.

undefined reference to `_IID_INetConnectionManager'
undefined reference to `_CLSID_ConnectionManager'

I am using Code::Blocks and Windows XP.

Also I have the following headers/libs
windows.h
objbase.h
Netcon.h
libole32.a

sfuo 111 Practically a Master Poster

What program are you drawing all your textures in?

I had that problem when I was using photoshop to make my textures because it feathers out and keeps some of your key color (transparent).

I switched to MS paint and wrote a program that converts 24 bit BMPs to 32 bit TGAs.

sfuo 111 Practically a Master Poster

The reason why the boarder is gray is because your clear color is gray. As for why it is not scaling up is unknown to me without seeing your glTexParameteri() functions.

When I made my tile game I used:

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

Unless you know exactly what each of them do I would suggest playing around with them a whole bunch and seeing what they do. For me when I did not use GL_CLAMP_TO_EDGE I noticed texture ripping between each tile.

sfuo 111 Practically a Master Poster

here are a bunch of games/applications that use OpenGL.

And you said other than WoW even tho that uses both Direct3D and OpenGL (depending on platform).

OpenGL and Direct3D are just like mac and windows, people have their preferences.

sfuo 111 Practically a Master Poster

The format of your if() statements is completely wrong.
The structure is:

if( condtion == value )
{
	//actions		
}

So for your Addition check you want something like this.

if( a == "add" || a == "+" )
{
	cout << "the answer is ";
	cout << addition(num1, num2) << endl;
}
else if( a == "subtract" || a == "-" )
{
	//and so on	
}

Things to notice are that you cannot just put if(a == "add" || "+") because "+" will always be true therefore it should always run (test it out).
Also using an elseif() statement for makes it so if you are doing addition then you do not have to check the subtraction/multiplication/division if() statements.

For your division check just put in an if() statement that checks to see if num2 is equal to 0 and if it is then output "Cannot divide by zero!" or something and otherwise output the answer. I am 100% sure that you can multiply by 0 so I think it was just calling your division function even though I'm not sure how that code even ran.

sfuo 111 Practically a Master Poster

Why don't you just get input as a string and go through it and store all the numbers into a new array.

for example:

#include <iostream>
using namespace std;

int main()
{
	string line, flipped = "";
	cout << "Please enter a string of numbers (ie \"12345\"): ";
	getline(cin, line);

	for( int i = line.size()-1; i >= 0; i-- ) //iterate through the string backwards
	{
		if( line[i] >= '0' && line[i] <= '9' ) //pick out all the numbers
			flipped += line[i]; //add them to the end of the new string
	}

	cout << flipped << endl;

	return 0;
}
sfuo 111 Practically a Master Poster

There are quite a few problems with this code.

#1) The run-time error is caused because you are trying to remove the first two digits of your decimal input and it is crashing because you use the itoa() function which takes an integer and converts it into a cstring. You are using a double which if it is less than 0 it will be put in as 0 (because an integer is a whole number and does not hold any decimal places). Then you try to substring that and say start at 2 and copy the next 2 elements. Since your string is only holding "0" you are trying to cut it out of bounds therefore making it crash.

#2) Another problem that you would run into later would be the fact that you are allowing an input of "0.01". This resistor would be Brown, Black, "??" (something that is 10^-3), Tolerance which doesn't exist on the 4 band resistors. Meaning you have to limit it to "0.1" because that would be Brown, Black, Silver, Tolerance.

To solve problem #1 I would completely scrap the function itoa() since it is old and uses cstrings when you are just converting them into strings afterward anyways. Use the stringstream object (you already have the header added and use it elsewhere) to insert your resistance after doing bounds checking then find the two significant digits and where the decimal place is to determine the multiplier.


I have …

jonsca commented: Nice job +14
sfuo 111 Practically a Master Poster

Try calling srand() right at the top of main() and only do it once (delete all the other times you call it). I did this and it seemed to fix the problem with the player getting dealt the same card twice.

sfuo 111 Practically a Master Poster

On line 22 you are setting space to 1 when you increase the length. I'm pretty sure if you take that line out you should be good.

sfuo 111 Practically a Master Poster

On line 11 of what I posted the while() loop will run until the end of the file.

sfuo 111 Practically a Master Poster

You need to make sure it is a project and then click the blue gear to build and the blue arrow to run.

If that doesnt work then you should make sure you downloaded the install with MinGW.

sfuo 111 Practically a Master Poster

Are you including both in main.cpp? This could be your problem and the solution is to use preprocessor blockers

SortData.h

#ifndef SORTDATA_H
#define SORTDATA_H

class SortData
{


};

#endif

And do the same thing for InsertionSort.h but with a different blocker name

sfuo 111 Practically a Master Poster

Since you know the data is separated by a ',' then you have to read in the data in chunks between the ','.

Below is some code I quickly threw together that takes in the data from the text file and stores it into data[].


data.txt

abc,cde,fgh,jkl,rty
qwe,erty, tyujk,werty,lkjh

main.cpp

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

int main()
{
	ifstream in("data.txt");
	int sz = 5;
	string data[sz];

	while( getline(in, data[0], ',') )
	{
		for( int i = 1; i < sz; i++ )
		{
			if( i == sz-1 )
				getline(in, data[i]); //since the end of the row ends with a \n
			else
				getline(in, data[i], ',');
		}
		
		//do stuff with the data here

		for( int i = 0; i < sz; i++ )
			cout << data[i] << " ";
		cout << endl;
	}

	return 0;
}
sfuo 111 Practically a Master Poster

This depends on what you mean by graphics. OpenGL/GLUT since GLUT makes it very easy to use graphics without knowing anything about OpenGL.

sfuo 111 Practically a Master Poster

Here is what I threw together to load in the board, print the board, count the sheep and remove sheep so you can test to see what is going on on the board.

Based on the fact that you are inputting 6 sheep and always getting 13 tells me that you aren't actually modifying the original board array or something else is going wrong.

data.txt

x x F . F x x
x x . . . x x
. . . . . . .
. . . . . . .
S S S S S S S
x x S S S x x
x x S S S x x

main.cpp

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

void LoadBoard(char board[][7]) //loads the board info in from data.txt
{
	ifstream in("data.txt");
	for( int i = 0; i < 7; i++ )
		for( int j = 0; j < 7; j++ )
			in >> board[i][j];
	in.close();
}

void PrintBoard(char board[][7]) //prints the board
{
	for( int i = 0; i < 7; i++ )
	{
		for( int j = 0; j < 7; j++ )
			cout << board[i][j] << " ";
		cout << endl;
	}
	cout << endl;
}

void CountSheep(char board[][7]) //counts how many sheep are on the board
{
	int sheepCount = 0;

	for( int i = 0; i < 7; i++ )
		for( int j = 0; j < 7; j++ )
			if( board[i][j] == 'S' )
				sheepCount++;
	cout << …
sfuo 111 Practically a Master Poster

Honestly that doesn't tell us anything. I was looking for something with sheep in it and some fox so we could run it and see where the problem is.