Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> Please name some (other than the obvious Iraq)
>> >> * don't take that too seriously.

I was being sarcastic, Dragon! I didn't actually mean it. Against the certain possibility that my sarcasm wasn't recognised I even put an astrix with a footnote there.

But Iraq.

Oops! you are right -- I didn't read your post close enough :icon_redface:

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

democracies have a horrible tradition of starting them

Please name some (other than the obvious Iraq)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Brazil -- love their nuts

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There isn't a tutorial but there is some information to help you, such as these google links

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You start by not using a dead language like Delphi. Then spend about 5 years or so learning how to write games with a real language such as C or C++.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Holland -- Tiptoe Through The Tulips :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I am using Visual C++ version 6. I need to know how to add a .lib file to a project. I want to add it as a static lib file.

Project --> Settings --> Link Tab --> change Catetory to Input then add the library to the Object/library modules list. In the left pain, change Settings For to All Configurations

iamthwee commented: retarded -2
Duki commented: equilization at hand. :) +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Although you didn't attach the list it is obvious that the error message means you are now linking to the wrong libraries. You need unicode version of the libraries from wherever you got the non-unicode libs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you should probably use a switch statement instead of a series of if statements, unless your assignment requires if statements. Move the last statement (lines 50-54) to the beginning so that its tested first, then put else statements before each if statement, like you did on line 50.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I am sure that 90% of people in the United States would not participate but then complain about the decisions made.

Isn't that about the way it works now ? :(

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

. Democracies never work because a large amount of people cannot run a government.

What about Switzerland ?

Switzerland provides the strongest example of modern direct democracy, as it exhibits the first two pillars at both the local and federal levels. In the past 120 years more than 240 initiatives have been put to referendum. The populace has been conservative, approving only about 10% of the initiatives put before them; in addition, they have often opted for a version of the initiative rewritten by government. (See Direct democracy in Switzerland below.)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Same with identity cards
If you have a driver's license then you already have an ID card :)

>>or having to tell the government the moment I move house
Do you pay taxes ? Does the tax form(s) ask your address. If yes, then you do that doo.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

well, what do YOU think is the answer ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

as i described b4 ,I was asked this question by a friend which he had got in an interview.Thnx anyway.

Not an excuse. You should follow forum rules regardless of who originally asked the question.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> write a better implementation of this function.
You do it, we don't have the time. Of course if you would pay me $5,000.00 I will do it for you :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If the code you posted contains errors then nothing will happen because the compiler will not generate an executable program. The ocmpiler generates the final executable program only when you have fixed all errors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what has the code you posted to do with the two questions you asked ? My guess: absolutely nothing.

Please read board rules -- especiall the part about We only give homework help to those who show effort

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

initial values: a = 2 and c = 1

First iteration: a = (2 + 2) * 1 = 4
Second iteration: a = (4 + 4) * 1 = 8
Third iteration: a = (8 + 8) * 1 = 16
Fourth iteration: a = (16 + 16) * 1 = 32

assumptions: none. The code you posted provides all the information needed to figure out the answer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

no one is going to write the program or you, so you might as well read your text book and learn how to do it. Tables usually are two dimensional, with rows and columns and look something like below (I'm certain you have seen this before in hundreds of places)

1  2  3  4  5
2  3  4  5  6
3  4  5  6  7

To print the above table you need two for loops, one inside the other, one loop for rows and the other loop for the columns.


>>to find the table of any number
To find a table of what? Is it supposed to be a multiplication table ? Addition table ? you need to clarify the problem before you can begin to code it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If this is for a school assignment then you probably should not use the boost library without your instructor's prior permission because he (or she) may not be able to compile it on school computers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

So most say that dictatorship is more efficient than democracy...

Efficiency doesn't equate to better. Hitler was probably an efficient dictator but I very few, if anyone, will claim he was better. Sadaam Husane had a very efficient dictatorship, but hardly one that anyone could willingly choose to live under. The dictatorships I hear about in Africa are certainly not better than other forms of government.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

offtopic but the wig looks pretty stupid... Do all UK judges wear them?

LOL -- I recently recarpeted my house with carpet that looks very much like his wig.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
cout<<unsort[i]<<" ";
cout <<unsort[y];

These are not valid C programming statements.

you are right -- I'll move it over to the c++ board.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, if you don't give printf() the correct arguments then its behavior is undefined. But most likely it will assum the stack contains the correct arguments and use whatever is there. That's why a lot of people get core dumps or access violations then they have "%s" in the format string but fail to pass a valid pointer to a character array.

As I mentioned in another thread, some compilers will validate the parameters to printf() and issue warnings is they are not correct. I wish all compilers did that :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I can't, but my teachers like to say that if you don't do something right the first time, you end up doing it again and again to fix the problems
And your teachers are right. Sofware companies spend probably three times (or more) the money in program maintenance then in original development.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are a few free C++ classes that might be useful to do the database part especially if you plan to use something like an SQL server, MS Access, Orical or something similar. Access via C and C++ can be quite compilicated so its advisable to use a C++ class that someone else with more experience has already written and tested. That way you can concentrate your efforts on what goes into the database and how to get it out instead of the low-level mechanics of talking directly to the databas engine.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here are workable examples of getting all the files in a directory and all its sub-directories.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I'm surprised even compiles
Depends on the compiler. Some compilers check the first argument to see if any other arguments are needed and give warnings for mismatches. Other compilers don't care.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

from purely efficient point of view, dictatorship is obviously more efficient because only one person (ok maybe a small group of people) make all the decisions, eliminating all the problems and delays associated with allowing the citizens to cast ballots. And that is one of the reasons why we in USA do not have a democracy ("mob rule")

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Because the quick and easy way is usually more costly in the long run? :D

How's that? can you show an example?

You don't have to read it one byte at a time if that's what you're worried about.

// Get the binary data
char iobuf[1024];

while ( fileread.read( iobuf, sizeof( iobuf ) ) {
  contents += iobuf;
}

I don't think std::string class will work with binary data like that. I think the += operator will stop when it encounters the first 0 byte in the iobuf.


Why can't you do it? A string has the data() method, and I don't understand why (somestruct)iobuf is any different from (somestruct)contents.data() if they both have the same characters.

I don't see a difference either (1) if it works (see above comment) and (2) except that old farts like me just perfer using char arrays when the problem suits it better :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why not just do it the quick and easy way, assuming the binary file is no larger than the char buffer. If the size is unknown than we'd have to first find out the file size and allocate the buffer appropriately. In any case it will be a lot faster then reading the fine one byte at a time.

Also, make sure to open the file in binary mode, not the default text mode.

unsigned char iobuf[1024];

fileread.read(iobuf,sizeof(iobuf));

Aother problem with using std::string like that is that std::string can not be typecast into a structure like character buffers can. The contents of the binary file may well be a structure and reading it into a std::string would destroy that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Isn't it somewhere in the book of Revelations (Bible) that indicates we are in our final days when people are required to have a number tattooed on the forehead? I'm sure you said that in jest, but then ....

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What is a segway?

Didn't you look at the picture in that link ?:D

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are not supposed to use the value of an array element in the for loop condition, but use the max number of elements in the loop, something like this:

for (j = 0; j < 10; j++){
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Odometer is the name of the class, not of an object.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

IE7 is the best extension :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can have as many -I flags as you want -- just put a space between then on that CFLAGS line

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

But the link works perfectly for me.

It times out from here (USA).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to truncate the string at the spot where you want to stop printing. If you want the full string later then save that character in another variable and put it back after printing

char c[40], *pc, save;
int size;

scanf("%s", c);
size = strlen(c);
save = c[size-4];
// truncate the string
c[size-4] = 0;
printf("%s\n", c);
// now put it back
c[size-4] = save;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem is something before that function.

As a sanity check you should get into the habbit of always using braces even when not required by the compiler. It will help prevent a lot of bugs.

int matrix_add(int)
{
   int i, j;
   for(i=0; i<3; i++)
   {   
	 for(j=0; j<3; j++)
	 {
	      result[i][j] = a[i][j] + b[i][j];
          }
   }	 
   
   return (a+b);
 
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Have a look at this.

link doesn't work

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

c++ classes and their methods are not callable from C.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you created a windows program not a console program. The simplest fix to that problem is to start all over again, but this time when you get to the Application Settings window choose Console Application

[edit] what WolfPack wrote -- I didn't see it when I wrote this [/edit]


About the code you posted: If the file failed to open you can't write an error message to it. You probably want to use cout instead of the file handle that failed to open.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

O.K., thanks!
I'm downloading it now, although it took time to find a link to it. It's well hidden from some reason.
I hope it's full enough.

Thanks again!

Please post link:)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Or turn off UNICODE Project --> Properties -->Configuration Properties, then the value of Character Set property to Not Set

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

.

The do { .. } while(0) is to use the loop-variables in a new scope, so it won't mess up variables already defined in the function that calls the macro.

All you need for that is the braces, which do not cause extra code to be geenrated like a do-nothing do loop. Guess a good optimizing compiler will toss it out anyway.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That is C++ code, not C. To compile with a C compiler you have to move line 7 to immediately after line 2.

Why use a do loop ? It does nothing at all. You can achieve the same thing if you delete lines 2 and 20.

If malloc() fails on line 3 then the rest of the code must not be executed because it will cause an exception.

That macro would be better if it were a normal function because macros are expanded every time they are referenced, such will make your program a lot larger than it needs to be.

>>but it makes it almost impossible to track the origin of the memory allocation, when debugging.
You are not using your debugger very efficiently then.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
system("pause");

system(pause) is the best method.

Your response is just a tad bit late -- by almost two years! :-O

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a hint -- notice the placement of line 4 below. Also why are you asking to input Amount twice ? On line 2 and again on line 3 ?

cout << "Loan Amount: ";
cin >> Amount;
if (!(cin>> Amount))
{	
        cin.clear(); 
        cin.ignore(500,'\n');
        throw "Invalid number";
}
else if (Amount >1000000 || Amount < 1)
{
         cin.clear();
         cin.ignore(500, '\n');
         throw "Please enter up to 1000000";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No it isn't correct. Read my post #5 very carefully, the very first sentence told you where to put that brace. If you count the braces in the code shipped you just posted you will see that there is an opening brace missing. The opening brace at the top of your last post is misplaced. Move it down to where I told you it belongs.