mrnutty 761 Senior Poster
e lambda=5.32*10^-07

You do know that '^' is called XOR and is not "to the power of"
operator ?

10 ^ -07 != 0.0000001;

mrnutty 761 Senior Poster

Just a wild guess.

CGUIEditBox
C - c language?
GUI - graphical user interface
EditBox - edit box

CGUIFont
C - c language ?
GUI - graphical user interface
Font - font

CXMLWriter
C - c language ?
XML - Extensible Markup Language
Writer - writer

mrnutty 761 Senior Poster

Copied and pasted and the value I got was : 0.0004254 for PD

mrnutty 761 Senior Poster

Try
::px = ((rect.right - rect.left) / 2) - 60;

I am assuming there is a local variable hiding the global.

mrnutty 761 Senior Poster

Try cout.precision(25);

mrnutty 761 Senior Poster

Here is another way you might want to try. Its in c++ though.
You could try to convert it into c.

float GetFloat()
{
	std::cout<<"Enter a number please : ";
	float num(0);
	cin >> num;

	while(!cin)
	{
		cin.clear();
		while(cin.get() != '\n')
			continue;

		cout<<"\nPlease enter a number : ";
		cin >> num;
	}

	return num;
}

use it like this :

int main()
{
    float num = GetFloat();
   return 0;
}
mrnutty 761 Senior Poster

If you print them side by side then it would make a blank diamond
shape in the middle. So instead of creating different shape 1 by one,
try to think about the whole shape as one. In fact, draw it on a piece
of paper, and try to think of some logic.

1) How many spaces does the first row have?
2) What is the rate of increase in spaces and stars?
3) How is it mirrored?

mrnutty 761 Senior Poster

Here is one of my beginning projects last year :

const int row = 1;

	for(int i = 0; i < row; i++)
	{
		for(int j = row-i; j ; j--)
			cout<<" ";
		
		for(int k = i*2; k >= 0; k--)
			cout<<"*";	

		cout<<endl;
	}

	for(int i = row; i >= 0; i--)
	{
		for(int j = i; j < row; j++)
			cout<<" ";
		
		for(int k = i*2; k >= 0; k--)
			cout<<"*";	

		cout<<endl;
	}
mrnutty 761 Senior Poster

Its much easier than you are making it.

cin >> limitNum;

for(int i = 0; i < limitNum; i++) 
    cout<<i<<" ";
mrnutty 761 Senior Poster

Use Euclid formula :
Formula(wiki)

mrnutty 761 Senior Poster

The difference is re-usability. Imagine creating a program thats
stores tons of information about a person. If you needed to hold
that data for a lot of people. It would save you a lot of time, by using
classes instead of regular variables and functions.

mrnutty 761 Senior Poster

"This 2 pieces of code is equal"

well mostly the initializer list is more optimal than the second way.

mrnutty 761 Senior Poster

I think this is supposed to be a recursive pow() function.

mrnutty 761 Senior Poster

"so far I don't see a big difference between a class and a function "

WOW. Read Me

mrnutty 761 Senior Poster

Go for class structure. It will definitely be a lot easier and less work,
as well as more elegant.

Here are some ideas :

class Hero{};
class BigHeadMonster { };
class Items { };
class Story { };
Class Map { };

Pick a class, start implementing it, and go from there.

mrnutty 761 Senior Poster

for(int i = 0; i <= Flowers; i++){

change that to i < Flowers.

Also notice the error : "application wrote to memory after end of
heap buffer"

It says that you wrote into memory where you were not
supposed to. If thats the case, then look in your code where
you write into heap, and most likely, thats where you will find
your problem.

mrnutty 761 Senior Poster

Look up linked list in google. Try implementing it that way, and
the push and pop should be easy to deal with.

mrnutty 761 Senior Poster

thanks wild goose. Haven't worked with socket.

mrnutty 761 Senior Poster

try it.

mrnutty 761 Senior Poster

when I do

void filter(char* packet)
{

	for(int i = 0; i < 8; i++)
	{
		cout << "(" << int(*packet) << ")";
		packet++;
	}
		
	cout << endl;
}

It print's
(83)(65)(77)(80)(127)(0)(0)(1)
though, so that would mean the buffer contains that information right?

Thats weird. Try cout<<buffer before the function call , and in the function as well. See if they are the same.

mrnutty 761 Senior Poster

"will evaluate to false when packet==0"

Yes thats correct. The 0 identifies the end of the string. Any further
then its junk.

mrnutty 761 Senior Poster

Then your problem is the buffer thats being passed to it. I does
not contain what you want.

I assume that the problem is here:

bytesReceived = recvfrom(incs.cl, buffer, 1024, 0, (struct sockaddr *)&clSockAddr, &fromlen);

Check if bytesReceived is the correct number of bytes you want to recieve.

mrnutty 761 Senior Poster
void filter(char* packet)
{
    int i = 0;
	while(packet[i])
	{
		cout << "(" << int(packet[i]) << ")";
		i++;
	}	
	cout << endl;
}
mrnutty 761 Senior Poster

Is the string a char of digits or characters?

mrnutty 761 Senior Poster

If I am reading correctly, you want to show packet as an int, via this
function?

void filter(char* packet)
{
	while(*packet != 0)
	{
		cout << "(" << int(*packet) << ")";
		packet++;
	}	
	cout << endl;
}
mrnutty 761 Senior Poster

use a for loop.

mrnutty 761 Senior Poster

Post your whole current code

mrnutty 761 Senior Poster

Just by looking at your errors :

You forgot to include proper library. Fastest way is to
#include<iostream> using namespace std; Although its not good
practice.

mrnutty 761 Senior Poster
mrnutty 761 Senior Poster

which line does it point to?

mrnutty 761 Senior Poster

I am not good at taking people's word. ;) Why does (float)rand()/RAND_MAX have low odds of generating 1 and how does it justify adding .1 in all cases?

It has low odds of generating 1 because for rand()/RAND_MAX to be
1, rand() HAS to generate RAND_MAX in which the odds are
1 out of 32767(RAND_MAX). Percentage wise its 0.000031.

In using 0.1f, it shifts the chances by a little bit more.

When (float)rand()/RAND_MAX generates 0.9 through 1.0, adding
0.1 would make it range from 1.0 to 1.1. This result gets multiplied to max-min, and since its an int it would not cause this function to
generate a higher number than max, unless the offset if set to
0.5 instead of 0.1, then it has a chance.

So the chances increases because now rand has to only generate
a number greater than 0.9 * RAND_MAX to get a 1. And that chance
from my calculation leads to 0.10 percent of generating maxNum.

mrnutty 761 Senior Poster

Here is another random generator :

int  randI( int min , int max)
{ 
    return    (float)rand()/RAND_MAX * (max-min) + min;
}

since generating 1 from (float)rand()/RAND_MAX has low odds, thus returning max would be low, so to fix it
you can shift the odds by adding 0.1f;

so the function would look like this :

int  randI( int min , int max)
{ 
    return    ( 0.1f + (float)rand()/RAND_MAX  ) * (max-min) + min;
}
mrnutty 761 Senior Poster
mrnutty 761 Senior Poster

.

mrnutty 761 Senior Poster

#include "Employee Class.cpp"

There should be no space between the name , it should be

#include "EmployeeClass.cpp"

mandofl commented: Gives good advice +1
mrnutty 761 Senior Poster

rand() % 15; // ranges from 0 -> 14
wildgoose, would you mind explaining you snippet a little "bit" more?

mrnutty 761 Senior Poster

Is that your class haven't learned arrays, or that the teacher
said you can't use arrays. How about emailing your teacher.

Btw, you need to seed your random number generator like so : srand(time(0));

mrnutty 761 Senior Poster

Can you use pointers and dynamic memory?

mrnutty 761 Senior Poster

You can use the indexes, but you can also use flags.

First try to read in a file. Then check for the first quote ( " ) and
if found read in the data until another quote ( " ) is found.

mrnutty 761 Senior Poster

It alls here :

{
			switch (choice)
			{
			case 'a':
			case 'A': cout << "You are accelerating the car. ";
				cout << Accelerate(first) << endl;
				break;
			case 'b':
			case 'B': cout << "You have choosen to push the brake.";
				cout << Brake(first) << endl;
				break;
			}
		}while (toupper(choice) != 'C');

You need to use the member to call the function Accelerate,and
brake, like so first.Accelerate(...), first.brake(...), and also you
are missing a bracket.

//Process the user's menu selection
		{ <--//either remove this or
}   
                    } //<-- or add this.
		}while (toupper(choice) != 'C');
mrnutty 761 Senior Poster

If not defined the compiler create a :

default constructor like so someClass() { }, that does nothing
default destructor like so ~someClass() {}, that does nothing
default assignment operator
default copy constructor
default address operator

mrnutty 761 Senior Poster

If maxNum is multiple of 100 the I guess you can do this:

if(maxNum%100==0)
maxNum %=99

max*=19;

mrnutty 761 Senior Poster

Oh wait My bad.

mrnutty 761 Senior Poster
ike this : 3,13,23,33,43,53,63,73,83,93 ?

yes like this.

Looking at this you don't even need a for loop.

Look at the pattern : 3,13,23,33,43,53,63,73,83,93,103,113,123,133...

It seems that there is 10 3's in every 100;

so ask user for max num;

set maxNum %= 100;

multiply maxNum by 10; and you have your answer.

mrnutty 761 Senior Poster

"(1) how to capture number of occurrences of 3 between 1 to 100? "

Like this : 3,13,23,33,43,54,63,73,83,93 ?

mrnutty 761 Senior Poster

You don't need a copy constructor for that. Only if you are using
dynamic memory, then you will need a copy constructor. The
std::string is it self dynamic and thus you don't have to keep
track of heap memory for it, the stl does it for you.

mrnutty 761 Senior Poster

if you don't want to get the user's input as a string you can
do the following (not tested) :

int num = 0;
 cout<<"Number please : ";
 cin >> num;

 while(!cin)//if input fails
{
   cin.clear();
   while(cin.get() != '\n')
     continue;
  cout<<"\nInvalid Input\n";
  cout<<"Try again : ";
  cin >> num;
}
mrnutty 761 Senior Poster

looking at your .txt file, you have the row and column backwards
in declaring your tmp array variable.

mrnutty 761 Senior Poster

No!!!


These are the exact same thing. If the block of code to be executed is only one line, no brackets are needed, though they don't hurt.

True. The compiler doesn't care of which way you use it,however, since
you are starting, you should use brackets so you can save mistakes from happening.

Salem commented: A consistent approach over option syntax will definitely save trouble at some point - good +36
mrnutty 761 Senior Poster

Maybe not killed, but laughed at, and your colleagues will implant viruses on your computer.

After that, who would want to live?