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


AD?!?! Really? Don't you mean getchar() ? :icon_wink:

Yes :icon_redface:

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

line 6: it would be more efficient if you passed the structure by reference (pointer) instead of by value. Note the asterisk below. You have to make similar change in the actual function. void proceed(struct registration* com, int matric); line 32 and other similar lines -- you don't put the data type in the parameter list, just the names of the variables you want to pass to the function.

You have lots and lots of other errors and missing parameters. Look at each error message that your compiler produced and fix them one at a time. Recompile after each fix to remove other related errors that are not necessary to fix. Then after fixing the compile errors you will have to deal with the logic errors.

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

a toilet

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

Here is the program I used using VC++ 2008 Express. And why is the value of RAND_MAX so much larger than mine ???

Its not my understanding that the OP is taking 10 samples and each sample size is 1000000 * 2 random numbers. But I see what you are attempting to prove is that the average is 2000000 random numbers is very close to the same each time it is calculated. I found that also, but posted only one sample, not 10. My first post was just simply 10 random numbers. The second post was the average of 1000000 random numbers.

#include <ctime>
#include <iostream>
using namespace std;
const long maxcount = 1000000;
int main()
{ 
    int i;
    _int64 sum = 0;
    srand((int)time(0));
    cout << "RAND_MAX = " << RAND_MAX << "\n";
    for(i = 0; i < maxcount; ++i)
    {   
        long x = rand();
        sum += x;
    //    cout << x << "\n";
    }
    _int64 avg = sum / maxcount;
    cout << "avg = " << avg << "\n";
        
    return 0;    

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

>>and some constructive criticism
ok, here goes

>> void main()
never use it. Read this:

lines 13-19: that an onconventional way to initialize variables. It will work, but that form is rarly ever used. more commen is int iTurn = 1; "\n" is usually preferred to endl because endl also performs unnecessary flush.

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

Maybe that's true in theory but it doesn't work out very well. Here are 10 random numbers and none of them except 1 are very close to RAND_MAX, and the average isn't even close.

RAND_MAX = 32767
23510
8870
11358
32748
20883
23642
20162
18820
1215
11317
avg = 17252
Press any key to continue . . .

But if I let the program get 1000000 random numbers the average is almost exactly in the middle of RAND_MAX. But I think for the purposes of the OPs problem almost isn't good enough.

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

The main problem with that is that the symbol flush is also declared in std namespace. When you have using namespace std; you include everything in the entire namespace in your program. That is one of the dangers of using that statement. If you replace that with only want you need in your program than the ambiguous symbol error will go away

#include <cstdlib>
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::string;

// rest of code here

Now, after getting past that, the next error is on the line you noted: and the reason is that you defined another symbol named flush that hid the original array named [/b]flush[/b] (see line 146) Delete the bool declaration on line 146 because it isn't used anyway.

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

my program REALLY doesnt like that += thing you did...

it runs the program but crashes? It gives an error to that line.

Post your code. You have to fix up all the other errors that are in your code such as declaring variables. After doing that your program compiles ok for me using VC++ 2008 Express.

>>that += thing you did
That is just shorthand for sum = sum + result; The two are identical, but you will find youself using += as you gain more experience to save keystrokes.

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

In the first program, last line, total is undefined.

and flush is undefined in the second program. Without seeing the entire program I can't tell you why.

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

All you have to so is sum up all the random numbers and divide the total by however numbers were generated. Its 4th grade math. The last line below is the average.

long long sum = 0;
srand(time(0));
long repeats = 0;
while(repeats < 1000000){

x = rand();
y = rand()

result = x + y;
sum += result;
cout << result << "\n";

repeats++;
}
cout << "Average = " << sum / (repeats * 2);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Any ideas?
You don't have to actually save each individual number in order to calculate the average. But if you want the values for something else then save them in an array or better yet in a file which doesn't take up much RAM.

And my guess is that the sum of all those random numbers may cause data overflow meaning that its impossible to get the average. Your best bet would be to save the sum in a 64-bit integer, such as _int64 or long long.

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

why don't you post the code that actually gets the errors. What you posted is what you want to do but not necessarily what you actually did. I know what you are attempting on line 11 can be done because I've done that quite a few times too.

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

Lol

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

Do it the same way that I said you can change the mouse in your other thread. Seems like you are attempting to write a prank program ?????

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

>>i have 3 days remaining to have my thesis...
I take it you are in graduate school ? And you don't know how to write that program? I hope you don't plan on teaching c or c++ anywhere.

Writing that program is pretty easy.

int value = 10;
printf("%02d ", value); // displays decimal
printf("%02X ", value); // displays hex
printf("%02o ", value); // displays octal
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

not really. try 1.0, 2.0, 3.0, 4.0, 10.0
what is required is the number with the ordinal rank of 3.

1 + 2 + 3 + 4 + 10 = 20
20 / 5 = 4

I think you are right :)

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

After getting the input string you could validate the string by first checking the string length to insure it is the correct length, then enter a loop and use isdigit() to check that each character is a digit or compare with ':' for a colon. If it passes all that then you could separate the input string into individual integers then validate again for valid ranges of hours, minutes and seconds. Finally convert all to seconds.

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

Actually we did finish it in about a couple months. The war since then is not the same war as we started with. We are now and have been fighting a war with Iran in Iraq. Had Israel done what we did than one of two outcomes would have occurred: (1) Isreal would now be fighting Iran as we are doing, or (2) Iran would have just taken Iraq for themselves because Isreal would have left as quickly as they went there.

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

you could sort the numbers then its easy to find the middle one. Or add them all up, divide by 5 then check each of the numbers to find the one that is closest to that.

5.63 + 10.5 + 16.7 + 20.6+ 10.9 = 64.33
64.33 / 5 = 12.866
Now, just like the bids on The Price Is Right, the number closest to 12.866 without going over is the winner.

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

Wow, and here I thought that "Jeb" was the nicest of the Bush sons. He would get the Florida Latino vote.

Don't care if he would get 100% of the Florida vote -- his last name is Bush. About 4 years ago where I live a candidate for state governor lost because of his last name -- the governor with the same last name was a scoundrel and is now serving a prison sentence.

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

Where is your proof that the BBC is a "pro-terrorist" news organization? Looks to me like you have none!

Agree -- its up to the accuser to prove his statement(s). The accused does not have to prove anything. Just saying "read the news" doesn't prove anything. Post links and quotes to the articles that support your position, to do otherwise just shows that you are blowing so much smoke and expressing some preconceived position.

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

Maybe John Sidney McCain III and John Ellis Bush (JEB) would be a nice ticket.

Never ever in this lifetime! I'll move to Netherlands first (well, not really but you get the idea)

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

The answer is still the same -- you need to know sockets and how to write clinent/server. Its not a very eash task, and what you describe might take you 1-2 years to complete.

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

I think you need to study c++ until you have learned it well before attempting to do complex things like sockets, server/client, networks.

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

Censorship is not always bad -- often serves some good purpose such as deleting government secrets (classified material), company secrets (such as how do they put the M on a piece of M&M candy?), criminal offenses of underage children, adoption papers, and the list goes on and on. We the public do NOT have the right to know everything about everybody.

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

im sorry for the late reply to my thread... and im sorry if i dont give the full info about this problem... honestly speaking i dont know how, when, where, to start this project cause i already forget my last lesson about C last year...

by the way... here are some of my last work and i really dont remember how i done this thing...

Why don't you dig out the book(s) you used last year and refresh your memory. If you are taking a more advanced course right now you will never get through it until you understand the material that was previously presented to you.

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

i already asked my prof. about the source for the table and my prof. told me to use this link as my guide http://ascii.cl/conversion.htm and she also said that i will only use only the decimal, binary, hexa

Already posted that one earlier, but I guess some people never read what people post to their threads.

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

examcode is just a simple integer (line 8). Good God man why don't you try reading your own program for a change and find out what causes the errors.

Nick Evan commented: excellent suggestion :) +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post an example of the input data you tried. Maybe what the controlller did was feed your program bogus (invalid) data to see how your program would handle it.

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

Assuming you mean MS-Windows, then maybe windows hooks

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

ok i will create than soon and will post it when i ma online again bye

Great. I don't be back online for about 8 hours (sleep time for me) so if you post quicker than that maybe someone else cal help you.

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

You can't link/or run that code because too many compile errors that you have to fix. Here are a few of them.

line 86: you forgot to change i to k.

lines 95-98 are not inside a loop, so I don't know what they are supposed to do. Looks like a posting error and those lines should just be deleted.

line 118: setw() doesn't take a float -- must be an integer.

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

ok can you help me can i get some sample of your own?

Yes we can help you but we will not write the code for you. I think everyone has given you enough information for you to attempt to write the program yourself. You will get no more help from me until you show at least some effort to write the program yourself. Post your code.

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

>>how to initialize the code?
That means to set it to 0 or some other value, such as int exam1 = 0;

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

i can't get it again i am newbie in that problem can you help me how to create it that as simple one? using #include<dos.>

why don't you try posting some code for a change ? Look in your textbook and see if you can't figure out how to get the program started with just the include file and main function. That is as basic as it can get.

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

If you don't understand it then you are attempting to do something that is over your head. Go back to the beginning of your text book and study the material again. This time do all the problems at the end of each chapter. The two functions getdate() and setdate() require that you know about structures. Study that material very very carefully until you get it straight in your head. Until you do no one in the world can help you very much.

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

your teacher is an idot then!

open up dos.h in notepad or some other text editor and search for getdate. Here's what you will find: extern void __cdecl getdate( struct date *datep ); That tells you that in order to get the system's date/time you have to pass a pointer to a struct date object that you create. that structure is also defined in that header file.

struct date dt;
getdate(&dt);

Simple, right?? That's all there is to it.

Now do the same with setdate() void _Cdecl setdate (struct date *datep); So to set the date just fill in a struct date and pass a pointer to it to detdate

struct date dt;
// fill in the structure is not shown here.
setdate(&dt);

Again, that is pretty simple stuff and straight forward.

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

>>main\63.cpp(119) : warning C4715: 'main' : not all control paths return a value
Looks like you left off the return 0; at the end of main().

>>main\63.cpp(87) : warning C4700: local variable 'exam1' used without having been initialized
That error should be obvious if you look at the line in the code -- you are attemtping to use an uninitialized variable. The value of the variable on that line contains any random value, which is a no-no if you want your program to work correctly.

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

yea that's I have C# that I compile at my school then when I compile at home with VC++ 8.0 Express I have to re-write the whole thing big pain in the....

Why are you using VC++ 8.0 at home ans C# at school? Get a C# compiler (free) to use at home and you won't have that problem :)

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

never heard of getdate() and setdate(). But time.h, or ctime, has similar standard C functions getsystime() and setsystime().

[edit]After looking at the link Nick posted I realize they are not the same afterall.[/edit]

@technogeek: (you name is a misnomer). If you scroll down to the bottom of nick's link it will give you a few illstrations how to use that function.

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

He initializes 'i' the first time in line 63 then he re-initializes it in line 85

just change the int in line 85 to like 'k' or something... should fix that problem.

you are trying to assign the variable i two different values (C++ doesn't like that) if you just get rid of the 'int' initialization in line 85 or change it to a different variable label should fix the problem.

You are right but some compilers like VC++ 6.0 do not follow the rules and allow that construct. Errors like that are common when attempting to port a program written with VC++ 6.0 to a compiler such as VC++ 8.0 Express -- been threre and done that too :)

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

What is mean by this statement? I dont understand, can someone explain to me?

loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
The thread 0xC4C has exited with code 0 (0x0).
The program 'C:\Documents and Settings\ashida\My Documents\MASTER C++\main\Debug\63.exe' has exited with code 0 (0x0).

Just ignore it as it doesn't mean much to anyone. All that is telling you is that your program is not using the debug version of the dlls that are mentioned. It does not affect your program in any way.

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

line 53: you have to use printf() to do that. puts() only accepts one parameter and that is the string that is to be displayed.

I don't know what other errors you want to know about. You'll have to be very specific.

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

what line number?

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

Static methods can not call non-static methods. You will have to design some other solution to calling that method, such as making it static also.

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

Welcome to DaniWeb -- looking forward to seeing you around frequently.

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

nothing wrong with the code you posted, but wrong with the conversion from London time to your time. Its not quite that simple -- if the result of the substraction is negative then add 12 hours, such as -4 + 12 = 8 PM. To keep the code you already posted you could then add another 12 to put the result into military time -- 8 + 12 - 20

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

I think the problem is with ostream -- you missed the namespace either std::ostream or add using namespace line.

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

add getch() just before the return statement so that you can see the output. Otherwise your program works just great.

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

Initially assume its AM.
To convert: if the hour is greater then or equal to 12 just subtract 12 and make it PM

11:30 is still 11:30 AM
12:30 becomes 0:30 PM
18:30 becomes 6:30 PM