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

I don't know whether the IDE is buggy or not, but it is distributed with an outdated version of MinGW compiler and has a lousy debugger, not very programmer-friendly. Since its no longer being updated, such as with a current version of MinGW, programmers should stop using it and get Code::Blocks instead. CB is not only a nicer IDE, but it has a decent debugger and is distributed with current version of MinGW.

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

ArtifiocialPerson clone(pseudorandom21)

Not funny, and tasteless.

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

Reads like an episode of Candid Camera :)

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

for line 13 your compiler is correct. names is an array of 1024 pointers, which are unallocated, meaning they point to no memory. You will have to allocate memory for them before they can be used. An easier way to do this for your program is to just hardcode the memory on line 7 char names[1024][40]; This allocates memory for 1024 names, each name can be up to 40 characters. That should be more than enough for your program.

Then on line 10 you have to index into names array using the loop counter, fscanf(file,"%s", names[i]); Now line 15 is something like line 10. On line 7 remove the * so that it allocates 20 floats, not 20 pointers. Then on line 15 do this: fscanf(file,"%f", &rates[i]);

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

That's called burnout. Take a vacation from programming for awhile to regain your enthusiasm. It happens to everyone on occasion.

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

EOF is added by the compiler at the end of each file not by user ok sir. so dont b sad

Wrong. The compiler has nothing to do with EOF. The compiler only converts the program source code to binary so that the operating system can execute it, and does nothing to the contents of a file.

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

I hope you are not a native English speaker :)

1. 0, I don't drink alcohol any more.

2. I have no clue what that question means.

3. Or this one either. "keep it up?" in USA usually refers to a man's penis.

4. Don't know about this one either.

MosaicFuneral commented: "keep it up" nice. +0
debasisdas commented: "keep it up" Melvin :) +0
T.Rex commented: Keep It up +0
happygeek commented: arf :) +0
jingda commented: Lol. I like your thrid answer +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's illegal here to have unpaid interns doing anything at all useful to the business.

What makes you think interns do anything useful :) college credit should IMO be considered pay.

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

I think the explanation in this thread will solve that problem.

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

You should never use gets() anyway because it could cause buffer overflow errors. Use fgets() instead.

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

I vote for all of them because they all do a terrific job keeping out the spam and doing other moderator jobs that we normal people don't see. This poll is nothing more than a popularity contest, not one that tells who puts in the most effort doing mod duties. You should add SOS, Davy and Narue to the list because they also perform mod duties from time to time.

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

reg cleaners can do more harm than good. The only time a reg cleaner might be of any value is when you install and uninstall many programs that do not do a good job of cleaning up after themselves during uninstall. And even then its questionable to use one because the cleaner could wipe out important stuff in the registry that other programs may use. But if you want to use a reg cleaner anyway, always back up the registry before doing anything.

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

1. The null terminator is a character at the end of the string that contains '\0'. The example you posted could be rewritten like this:

char phrase[13] = {'G','a','m','e',' ','O','v','e','r','!','!','!',','\0'}; Its just a lot more convenient for us to type it as in your example, and the compiler will generate the correct code to null terminate the string.

2. You mean the quotes around [b] "Game Over!!!"[/b]? Yes the quotes are required so that the compiler knows where the beginning and end of the string are.

[edit]^^^ Oops he posted before I did.[icode]
char phrase[13] = {'G','a','m','e',' ','O','v','e','r','!','!','!',','\0'};
Its just a lot more convenient for us to type it as in your example, and the compiler will generate the correct code to null terminate the string.

2. You mean the quotes around "Game Over!!!"? Yes the quotes are required so that the compiler knows where the beginning and end of the string are.


[edit]^^^ Oops he posted before I did.

crapgarden commented: awesome +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A VARIANT is standard Microsoft structure used to pass object across COM objects. Use heavily in COM programming and to pass strings between VB and c/c++.

The vt member of the VARIANT object tells what kind of object the VARIANT contains. Then the remainder of the structure is a union of several object types, one that is commonly used to pass strings is BSTR. The BSTR itself is commonly encoded with UNICODE strings which are wchar_t* instead of char*. The length of the BSTR is actually a long integer stored 4 bytes before the beginning of the BSTR pointer. So if you want the length of the BSTR then its just like this:

BSTR b = SysAllocString( L"Hello"); // Create a BSTR

long len = *(long *)(b-2);

google will give you links to several threads that indicate how to convert from BSTR to char*. Here is just one of them.

Here is another good tutorial

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

Hi all!

I've read forward declaration is much prefered than include in header files mainly because it reduces the compilation time. Other reasons?

My particular situation is that all header files that I use are within a namespace. I've seen two different ways for forward declaration in this case:

namespace n1
{
class c1;
}

and

using namespace n1;
class c1;

I think the first one is better because I don't like the idea of the "using" keyword in a .h file. But with this method 1 line of include is converted into 4 lines for each include

Since I use 5 or more includes of 5 different namespaces the code increases quite a lot.

My question is...
Is there any other way of using this forward declaration but with that increment in source code lines?

any idea?

thank you all in advance!

Your first and second examples are NOT the same thing. In the second example class c1 is not declared to be in the namespace, while in the first example it is.


Lets assume you have this header file

// forward declaration
namespace n2
{
    class c2;
};

// this class uses the forward declaration
namespace n
{
    class c1
    {
    public:
    private:
        n2::c2* pC2; // use forward declaration
    };
};

Now in the *.cpp file just do this

#include "test.h"

int main()
{
    n::c1 object;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your compiler is correct. void main() is non-standard, the c and c++ standards require main() to return an int. Change your program to int main() and it will be standards conforment.

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

>>Some gd example are.

That is a perfect example why we should NOT use leet or chatroom speak. Does gd mean "god dam" or good?

Salem commented: rep toy++ +17
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its illegal to write viruses -- you can go to prison for that. I would castrate without anastasia those who do that if I could get my hands on them. Me hostile?? No, not one bit.

WaltP commented: I wouldn't use Anatasia either -- the Czar would be mad! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>*(mpg+ctr) = *(miles+ctr) / *(gallons+ ctr);

That's the same thing as this: mpg[ctr] = miles[ctr] / gallons[ctr]; Personally I do not like or use the pointer arithmetic as shown in your code snippet, but its just a matter of personal taste. IMO using the index method I show is a lot more clear what is going on, and of course requires little thinking about it. Programmers should write for clarity, not cuteness or an attempt to impress others.

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

Since | character is not a number you can not use cin>>num for data entry. Use sometime other than | for data termination, such as -1.

Second problem is that the Enter key '\n' is left in the keyboard buffer after numeric input. cin>>num does not remove it.

You need to do two things
1) clear the cin error
2) flush the input buffer of all remaining key values. See this link for the expanation

cin.clear();
    cin.ignore ( std::numeric_limits<std::streamsize>::max(), cin.widen ( '\n' ) );
mike_2000_17 commented: 954th thread about cin.ignore() on Daniweb! +11
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>however when i copy the structure definition to my code , it complains its already defined in time.h ?

You are not supposed to copy standard C structures into your code -- juse use the #include <time.h> statement .

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

There are lots of ways to create GUI ms-windows applications. One of them is by using CLR/C++ Windows Forms, another using wxWindows c++ classes, or pure win32 api functions

Here are a few tutorials for you to consider

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

1. No.

2. That does not add members to the structure, it declared 15 objects of the structure. A better way to do that is by using an array of structs e.g. jatekos array[15]; // declare 15 objects of type jatekos 3. Ok the code you posted here makes more sense. Here again, like above, you need to declare an array of those structures.

struct jatekos ja[15];

while(getline(tmp,20)>0){
   strcpy(ja[i].nev,temp)
   i++
}

//or like this, eliminating the need for temp array
while(getline(ja[i].nev20)>0){
   i++
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

must be a problem with your computer because IE8/9 has no problems with it for me. Don't blame M$ for something that may be your own fault.

But I also noticed its not DaniWeb but it happens everywhere.

WaltP commented: Of course it's my fault. I didn't set IE up. And since it can't figure out how I connect by checking the system itself, (and I don't like IE anyway) I'll just let it be a cripple. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why disappointing? DLLs never call functions in the application program (except via callback function pointers) -- its the other way around.

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

I don't have to real estate for two monitors. I don't need a monitor for each eyeball :)

jingda commented: Lol +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Please tell me how the two statements are related??? The Democrats did Obamacare all by themselves, not one Reublican voted for it and it still passed. That makes the Democrats the perpetrators of the biggest fraud in American history, with the exception, of course, of Obama's forged birth certificate. But that is a different store for another time.

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

I always used ODBC because its supported by most (all) SQL compliant databases and is well documents. You can even find free c++ classes that wrap the odbc calls.


If you are using MySQL then you can get MySQL++ which are c++ wrapper class for MySQL. That's a little different than odbc, and probably faster too.

For really small projects that do not require multi-user features you can use SqLite which does not require some external database engine such as MySQL or MS-Access. Its all self contained and is compiled right into the application program.

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

The first error indicates that you have called a time functon that does not exist. Read this thread for the solution to that problem.

The second error is quite simple. You created a MS-Windows project but you probably replaced WinMain() with main(). If you wanted main() then you should have created a console project.

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

Obamacare was destroyed by the Republicans (who were working on behalf of their corporate donors) by not provided a public option and thus just helping the insurance companies rip-off the American people.

The republicans had no say in passage of Obamacare. The Democrats controlled both houses of congress at that time. So I don't know how you can possibly blaim the republicans for anything.

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

6+2x10 is easy
but
I oftened wondered what 7+2x10 could be

You're kidding -- right ??? (27)

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

So the program converts the character into a number, as variables a & b are of int type and not char.

However, it should convert the character into its ASCII code, but I don't know why does it give such an odd output.

It does no such thing. cin produces an error and does nothing at all, leaving the value of the integer unchanged. The value that was shown in the output was just some random value that was in that memory location when main() was entered from the program's startup code -- which is the code that the compiler adds to the program and is executed before main().

You can easily verify this yourself by initializing the variables when they are declared, such as int a = 1, b = 2;

Derek Elensar commented: Agreed, using an "int" is not for storingletters and symbols, it's is used for storing non decimal numbers. When given another data type, it can't hold it, so it holds the value of the memory location where the data is stored +2
ilovec++ commented: Thanx, didn't know about it. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For anyone wanting to write his/her own os, you really need to go here.

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

In USA any 5th grade student should have known the correct answer. And Shame on anyone who is a programmer and doesn't know it.

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

26. Not much thought needed. 6+2x10 = 6+(2x10) = 26

Azmah commented: Great Job +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to get input as std::string then pars it to extract the integers and operators. Since they can be entered in any order there really is no other way to do it.

predator78 commented: exactly, didn't know this to be true with c++ but great info +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Any Advice/Idea!

If you expect the answer you want then you have to learn how to ask the correct question. I answered the question you asked, nothing more :)

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

I really disagree with you Ancient Dragon. They are not always run by tyrant. You are only talking about Soviet Union

Really?? I would classify the dictatorship in China in the same category, although AFAIK China is not really communist anymore either because it has been evolving into a capatilist country for several years now. In the same light, USA is not a democracy (or federalist) country any more either -- its evolving into socialism.

Salem commented: *nods* +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What you are describing is socialism, not communism. Communism asserts that the state owns everything, no private person can own anything, and that goods and services distributed among the people according to need. Also communism does not allow free elections, or free anything else either, such as religion. Communist coutries are run by tyrant dictators.

If your country were to suddenly come under communist control, everyone would immediately be tossed into the poor house. People with lots of education most likely would be shot (executed). Is that the kid of life you have in mind???

I doubt such a thing would happen in USA because we are too well-armed and would kill anyone who attempted it.

susheelsundar commented: Now this is Wiseness :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Nice -- bumping a 5-year-old thread with no new content.

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

line 11. There's the easy way to code it. Notice it does not do any seeks() or memory allocations because std::string will do all memory allocations for you.

// Player's Name
  std::string name;
  ifstream CharName("C:\\ZacarasEmpire-Offline\\Data\\File01.ze");
  if( CharName.is_open())
  {  
      CharName >> name;
      CharName.close();

      cout << name;         
      hEditName = CreateWindow(TEXT("STATIC"), name.c_str(), 
        		    WS_CHILD | WS_VISIBLE | SS_LEFT,
        		    40, 190, 100, 23,
        		    hWnd, (HMENU) IDC_EDIT_NAME, GetModuleHandle(NULL), NULL); 
  }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I see you never used pirate websites. I do not support piracy but I think current copyright laws are outrageous. If they do not change them there will be more and more piracy. I have about 8 friends in school who download pirate music and only 1 who actually pays for it! I think it is not fair and wrong. If you will just keep closing web-sites like piratebay more will pop-up and nothing will happen. What is needed is a major copyright reform.

So you don't think theft is wrong. Please give me your home address so that I can come over and steal everything you or your parents own. No matter how you want to justify it, theft is theft. Artists and record/music/movie companies work hard to create the stuff you like and you have no right to steal it from them.

There is not a thing wrong with our copyright laws.

jwenting commented: well said +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What everyone else is getting is probably illegal, so be careful that you don't get sued for downloading copright material.

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

There are a couple options
1. If your compiler supports conio.h then it contains a couple functions that will do what you want.

2. Use OS-specific api functions. For MS-Windows there are some console functions you can use (link here)

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

If this were a forum about English grammer then I would agree with WaltP. This isn't, so I don't. The important thing on DaniWeb is that the poster expresses him/herself as clearly as possible, not whether he dotted all the is or crossed all the ts. I don't really care if he uses "their" when "there" was intended.

diafol commented: You wrote what was on my mind +0
sergent commented: :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look at the logic of the code. Every time you select menu 1 the program allocates an entirely new array of Player objects. The previous array is thrown away, lost forever, and a memory leak occurs. If an array already exists then you need to figure out how to reallocate the array without losing any memory or the previous values in the array. This is one reason why programmers use the std::vector container, because it does all that for you so you can concentrate on the logic of your program instead of how to manage arrays.

And yes, the constructor has to be called for each item in the array, once for value of num_players.

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

line 52: where is player declared? The declaration on line 50 is not in scope at line 52, so it can't be used. Move the declaration of player from line 50 to just after line 42.

why is position a pointer? line 27 only allocates one of them. There is no point using a pointer to allocate a single integer.

predator78 commented: gettin me straightened up slowly but surely lol +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I wrote this script for my classmates where we shoot at each other
Remind me never to go to your school.

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

its nearly the same thing

string in = "123";
stringstream out;
out << in;
int thetime;
out >> thetime;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The technical specification lays out the requirements for the project, AKA project design document. It contains great details of the project, such as screen shots, menus, and a detailed description of the purpose of the project. A project could consist of multiple programs which all work for some common purpose, wuch as Windows Office and Open Office. Both these projects contain multiple programs. The author(s) of such technical specifications may find that it is necessary to split it up into multiple specification documents, such as one for Word, another for Excel, etc.

What will the documents contain? As I already mentioned they will contain as much detailed information about the project as humanily possible. If I come to you and ask you to write a program to help me manufacture widgets then you will write the technical specs to make sure that both you and I agree on what the program will look like and how it will behave. Without such agreement the project will probably fail or will cost you a lot more money then I paid you because you will have to re-write the parts that were not previously clarified. And if I come back again and ask for more changes the previously agreed upon technical specifications will give you justification to ask for more money to pay for the new requirements.

Finally, the technical specification is the document that the programming staff will use to write the program(s).