sfuo 111 Practically a Master Poster

I'm not sure because when I was doing some testing I made a char array size 2 and the size of it said it was 2 bytes in size but there were 5 characters in the array.

sfuo 111 Practically a Master Poster

You log in and click your name on the top left hand corner then click statistics >> Find all threads started by name. Then just select the thread that you want to go to. To mark as solved scroll to the bottom where it says reply to thread in a yellow box and just to the right of that is blue text that says mark as solved.

sfuo 111 Practically a Master Poster

Is it just dates in the file or is there more to it?

sfuo 111 Practically a Master Poster

misread let me think for a sec

sfuo 111 Practically a Master Poster

Is this what you are trying to do? Or are you putting it into a custom list type?

#include <iostream>
#include <time.h>
#include <list>

using namespace std;

void makeList(list<char> &inList)
{
	list<char>::iterator it;
	int j;
	for( int i = 0; i < 50; i++ )
	{
		bool isUnique = false;
		while(!isUnique)
		{
			char randChar = rand() % 26 + 'A';
			int makeLower = rand() % 2;
			if( makeLower == 0 )
				randChar += 'a' - 'A';
				
			for( it = inList.begin(), j = 0; it != inList.end(); it++, j++ )
			{
				cout << j << endl;
				if( *it == randChar )
				{
					break;
				}
				else if( j == inList.size()-1 )
				{
					inList.push_back(randChar);
					isUnique = true;
				}
			}
			if( inList.empty() )
			{
				inList.push_back(randChar);
				isUnique = true;
			}
		}	
	}	
}

void printList(list<char> inList)
{
	list<char>::iterator it;
	for( it = inList.begin(); it != inList.end(); it++ )
	{
		cout << *it << endl;
	}
}

int main()
{
	srand(time(NULL));
	list<char> myList;
	
	makeList(myList);
	myList.sort();
	printList(myList);
	
	system("PAUSE");
	return 0;
}
sfuo 111 Practically a Master Poster

For displaying arrays you do not just call the array its self you have to make a for() loop to output.

for(int i = 0; i < 8; i++)
{
	cout << arr[i];
}
sfuo 111 Practically a Master Poster

So I made a version of this that makes 50 unique chars from A-Z and a-z, stores them, sorts them and then outputs them. I am using the list container and not a structure like what you made. Ask if you want to see some code if this is what you are looking for.

sfuo 111 Practically a Master Poster

Your create list makes 1 random number. How many characters do you want in your list.

sfuo 111 Practically a Master Poster

Explain what you are doing here. Do you want to make a whole list of x size or just insert the 2?

sfuo 111 Practically a Master Poster

You could even use

rand()%('Z'-'A')+'A';

and this would give you a random char between them.

sfuo 111 Practically a Master Poster

I think its just checking from a list of options and if it is not there it throws you the error that it does not have a spawn function.

sfuo 111 Practically a Master Poster
#include <time.h>
#include <iostream>

srand(time(NULL));
	
char randChar = rand()%(90-65)+65;
int makeLower = rand()%2;
if( makeLower == 0 )
{
	randChar += 'a'-'A';
}

This generates a capital char then converts it to a lowercase if makeLower is equal to 0.

sfuo 111 Practically a Master Poster

So post some sample code of what you have so far. We don't hand out free code for assignments.

sfuo 111 Practically a Master Poster

Yeah OK it is bad for a large scale project and one that will be changed and maintained. For this example it doesn't really matter but what you are trying to say is it is bad practice and you should do it with proper structure.

There is a huge difference between wrong and a better and cleaner way. In this case no ways were wrong but I can see where you are coming from you just came across unclear at the start.

sfuo 111 Practically a Master Poster

I use devC++ and if I want to use the <cstring> library I do not need to use <iostream> or <iostream.h>. And I have never used MFC so I wouldn't know but since I don't use it you do not need to include it.

Frederick2 commented: thanks, you're right! +2
sfuo 111 Practically a Master Poster

I understand what you are trying to say with the inner and outer conditions and you would run into an error there but the outer condition is that the input has to be one of the inner.

I wrote a quick example to double check myself and found it worked how I expected.

#include <iostream>

using namespace std;

int funct(int input)
{
	if( input == 1 || input == 2 || input == 3 || input == 4 )
	{
		cout << "range of 1-4" << endl;
		if( input == 1 )
			return 1;
		if( input == 2 )
			return 2;
		if( input == 3 )
			return 3;
		if( input == 4 )
			return 4;		
	}
	else if( input == 5 )
	{
		cout << "is 5" << endl;
		return 5;
	}
	else
	{
		cout << "else" << endl;
		return input;
	}
}

int main()
{
	int input;
	
	cin >> input;
	
	cout << funct(input) << endl;
	
	system("PAUSE");
	return 0;
}

His code would not work if it was

if( input != alpha || input != number ) (meaning a symbol)
{
if( + ) return add
if( - ) return subtract
if( * ) return multiply
if( / ) return divide
//here would be an error because there is no return for other symbols however the other examples have cut out all that by making the "outer" if statement only take in the inner ifs
}
else if ( input == alpha )
return getVariable(input)
else
//all …
sfuo 111 Practically a Master Poster

I never said it worked in that kind of structure the way he has it set up it works like a switch. Read what he posted not what you snipped.2

sfuo 111 Practically a Master Poster

If none of those cases are true then it goes to the else if below.

sfuo 111 Practically a Master Poster

This is because you aren't assigning finalpaint and finalcost a value. Go double check your code.

sfuo 111 Practically a Master Poster

You have one of your cin's with operators going the wrong way << you want it >> like the rest of them.

Also, you have it so it compares the input to a variable that are not assigned. Either assign Apples, Oranges, Pears or change your if() statements to

if (fruit == "Apples")
if (fruit == "Oranges")
if (fruit == "Pears")

And I take it you are going to fix up the type because I could type anything in and it would say
You have selected "input" Apples.

sfuo 111 Practically a Master Poster

The function mazeTraverse() is pretty much this whole program. It checks to see if the position in the maze that is it at is a space and then if it is it runs its self 4 items (up one spot, down one, left one, right one) and doing the same checks as before and if those spots are spaces then it runs its self another 4 times. This happens until it comes to a dead end.

Not sure if that helps it took me a few secs to look at the function to figure out what it was doing.

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

Is this where it says the error is? Or can you post all your code if it isn't too long.

sfuo 111 Practically a Master Poster

You are calling calculate_Cost() with only one parameter when you defined it with two.

Also I see "***" at the bottom not commented and +- at the end of your calculate_paint() function.

sfuo 111 Practically a Master Poster

Why are you calling the prototype with no parameters? This would be the problem that I see.

sfuo 111 Practically a Master Poster

This confused me too but I went to http://www.cplusplus.com/reference/clibrary/cstring/ and looked up a cstring function that would work for this.

if( strcmp(input, "Synergy") != 0 ) return;

Returns 0 if they are equal.

sfuo 111 Practically a Master Poster

Try the function atoi() it is not used by all compilers but you can see if it works. Or take the value in as an int and use itoa() for adding the number to the end of the string.
(itoa() converts int to string and atoi() is string to int)

sfuo 111 Practically a Master Poster

Well we cant give you the solution 100%.

I know a bit about winsock for windows and I could help you make a client/server for it but you have to ask questions and I will help answer them.

sfuo 111 Practically a Master Poster

Yeah because you declared your class type 'animshapeO' not 'animShapeO'.

sfuo 111 Practically a Master Poster

You are trying to store text from art.txt to an int array. You gave your string[] variable an int type.

sfuo 111 Practically a Master Poster

I'm not 100% sure how you want to set up all your variables and parameters but here are a few things:
Use a character array (char var[]) for a parameter char* string.
For a const char* parameter and you want to use a c++ string then convert the string with .c_str() making it a const char* array.

You could make it work either way but you have to pick one and stick to it otherwise you are adding in lines of code to convert from one to another. Personally I would stick to C++ strings for this.

sfuo 111 Practically a Master Poster

I would take testpid in as a string or convert it to one and put

pKeyboardHelper = new CKeyboardHelper(("WindowerMMFKeyboardHandler_"+testpid).c_str());

This should work if not I'll look at another way.

sfuo 111 Practically a Master Poster

Can you post a quick input example that would be inside of the textfile.

sfuo 111 Practically a Master Poster

By the looks of it you want to be working with cstrings instead of the "new" C++ strings.

#include <cstring>
int main(){
	char input[100];
	cin.getline(input,100);
	return 0;
}

With this you take in a char array from getline() instead of a string and are able to pass it through your function SendText.

Or you can fix it without changing as much code by making it so SendText() takes in a UINT and string for parameters.

And for both you would remove the .c_str() attribute from input.

(I see you have std::cin, std::hex but you do not have std::string or std::cout meaning you are using the namespace std. Once you start using namespace std then you do not have to keep setting the scope.)

sfuo 111 Practically a Master Poster

A way you can do this is use the function

void SendString(const char* string);

and if your input variable is a string type then for passing it into the function put

SendString(input.c_str())
sfuo 111 Practically a Master Poster

Are you using the variable type string or char[]?

sfuo 111 Practically a Master Poster

If you are tying in "test test" it will put test for the 1st input prompt and test for the second. And this will result in giving you a single output of test.

remove std:cin >> input; ( scope is :: not : ) and this should work.

sfuo 111 Practically a Master Poster

I copied the code above and it says that it works fine but I cannot use the drand48() function. I googled it and its for linux or something?

sfuo 111 Practically a Master Poster

put

cin.ignore()

before the getline() code

sfuo 111 Practically a Master Poster

cin goes till a ' ' or '\n' character comes up.
getline() goes until a '\n' character.

sfuo 111 Practically a Master Poster

What do you want to know? Do you have a compiler?

sfuo 111 Practically a Master Poster

I'm going to assume scanf() is like cin in the way that it cannot take in spaces.
One way to use cin to take in spaces is to use getline(cin, variable).
Then use cin.ignore() if you run into a problem with the '\n' character skipping inputs afterward.

sfuo 111 Practically a Master Poster

I could help more but I've come to the problem of not knowing how to use this.

bool collidesWith(shapeO *)

What does * mean? As in how do I get information ( getRect() ) from it?

sfuo 111 Practically a Master Poster

Do you have to use the class word for word? Or can you change some return types and parameters.

sfuo 111 Practically a Master Poster

Your return value is the type of function that you declared.

For example if you make int sum(int x, int y) { return x+y; }
this function returns an integer.

Your return value is a set and that is a class type you defined.

It looks like you are just returning a value to say it did it. You could get away with declaring the function void and have no return value.

example

void multiply(const set &other)

but if you want it to return the value of the 2 sets multiplying then you want to return int for your num.

example

int multiply(const set &other)
{
return num*set.getNum();
}

I put the attribute getNum() in because num is declared private.

sfuo 111 Practically a Master Poster

Is this what you are trying to do?
This is a very general example

#include <iostream>
#include <string>

using namespace std;

string myReturn( string in )
{
	return in;
}

int myReturn( int in )
{
	return in;
}

int main()
{
	string strIn = "20";
	int intIn = 20;
	cout << myReturn(strIn) << endl;
	cout << myReturn(intIn) << endl;
	
	system("PAUSE");
	return 0;
}
sfuo 111 Practically a Master Poster

Yeah I haven't played around with the cstring lib and I use strings instead of char arrays so I read what Lerner said below and changed the sort() function.

void Sort(Student data[], int size)
{
	for( int c = 0; c < size; c++ )
	{
		int index = c;
		for( int i = c; i < size; i++ )
		{
			if( strcmp(data[index].Last, data[i].Last) > 0 )
			{
				index = i;
			}
			
			if( index != c && i == size-1 )
			{
				Student temp;
				temp = data[index];
				data[index] = data[c];
				data[c] = temp;
			}			
		}
	}
}

This works for what I've tested.
Don't forget to #include <cstring>

And I changed the infile while() loop to what Lerner suggested too

while( infile >> data[i].First >> data[i].Last >> data[i].Score1 >> data[i].Score2
		>> data[i].Score3 >> data[i].Score4 >> data[i].Score5
    		>> data[i].Score6 >> data[i].Score7)
{
	if( !infile.eof() )
	{
		size++, i++;
		temp = new struct Student[size];
		for( int c = 0; c < size; c++ )
		{
			temp[c] = data[c];
		}
		data = temp;
	}
}
sfuo 111 Practically a Master Poster

I'll check about the modification but the reason why the last guy gets cut off is because you have numstudents-1 in the for() loop for output.

sfuo 111 Practically a Master Poster

You have written

infile.close();

two times.

At the top of the outfile.open() section you have

Sort(data[i].Last, numstudents);

I think you are thinking of putting that into a for() loop or something to call that function once per person in the list.

If you are going to do a self made sort then I would send the whole list into 1 function.

example

void Sort(Student data[], int size)
{
	for( int c = 0; c < size; c++ )
	{	
		int index = c;
		for( int i = c; i < size; i++ )
		{
			if( data[index].Last[0] > data[i].Last[0] )
			{
				index = i;
			}
			if( index != c && i == size-1 )
			{
				Student temp;
				temp = data[index];
				data[index] = data[c];
				data[c] = temp;
			}				
		}
	}
}

This sorts the last name by the 1st letter not based off the whole last name.

sfuo 111 Practically a Master Poster

Give this a try.

ifstream infile;
ofstream outfile;
int size = 1;
    
infile.open("input.txt");
    
struct Student * data;
struct Student * temp;
data = new struct Student[size];

int i = 0;
while( !infile.eof() )
{
	infile >> data[i].First >> data[i].Last >> data[i].Score1 >> data[i].Score2
		>> data[i].Score3 >> data[i].Score4 >> data[i].Score5
		>> data[i].Score6 >> data[i].Score7;
        
	if( !infile.eof() )
	{
		size++, i++;
		temp = new struct Student[size];
		for( int c = 0; c < size; c++ )
		{
			temp[c] = data[c];
		}
		data = temp;
	}
}

infile.close();

I know this is constantly swapping between temp and data but its semi compact and gives the output I think you are looking for.

sfuo 111 Practically a Master Poster

I just copy pasted your code in and was looking for errors during runtime.

As firstPerson said, your for() loop is poorly done for keeping the program going till the user inputs -1 for quitting.

I would use a while() loop and put a bool variable done inside and if the user inputs -1 then done = true.

bool done = false;
int quit = 0;

while( !done )
{
	//.....
	cin>>quit;
	if( quit == -1 ? done = true : done = false );
}