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

The functions in time.h aren't at all difficult to use -- you just need to read about the different functions.

time() -- returns the current time in seconds since 1970. It returns the time in an unsigned int (size_t) variable. When you have to get the current time this is the first function you want to call.

localtime() -- takes the return from time() and converts it to a struct tm structure.

time_t now = time(0); // get time in seconds
struct tm* tm = localtime(&now);

From there you will easily see how to extract the hour and minutes from the struct tm structure. If you know how to use structures and pointers then this will be a snap for you.

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

I'm PG-13 rated. I hate potty-mouthed comedians/movies.

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

Yes, Dani made that change a few weeks ago.

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

line 17 is probably the wrong way to determine if the file is empty or not. What you should do is seek to end of file then get the file position.

instaffile.seekg(0, ios::end);
size_t sz = instaffile.tellg();
if( sz == 0)
{
    staffid = 1;
    return;
}

The loop at lines 24-28 is also wrong

instaffile.seekp(0, ios::beg); // go to beginning of tile
count = 0;
while( instaffile.read(reinterpret_cast<char *>(this),sizeof(staff))
{
     ++count;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You created a windows gui project, not a windows console project. Start again, but this time create the right kind of project.

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

Ha Ha!! Hello from windows 7 running on my netbook :)

What is a netbook? Never heard of that. :)

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

I suspect the larger buttons are to help newbes figure out how to post a new thread or a response to an existing thread. I've seen comments by a few people who didn't know how to do that most likely too inexperienced with posting on forums.

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

However, please note that when you enter text, you press the [Enter] or [Return] key and this character does not just vanish, it remains in the input buffer.

That is only true when using scanf(). Both gets() nor fgets() extract the '\n' from the keyboard buffer.

Dave Sinkula commented: A bump to defend gets()? -2
WaltP commented: Not a defense of gets() -- simply an observation on 2 functions we wish didn't exist. +11
Aia commented: I do not care for the observation. If we truly wish that it did not exist, do not bring it up in such a confusing statement. -2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The parameter to open() has to be a null-terminated character array (commonly called a string). All you are trying to send it is a single character. Try this:

int main()
{
int i;
char* letras[3] = {"a","b","c"};

for(i=0;i<3;i++)
{
    ofstream print(letras[i]);
}

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

win32 api was written in C so that it can be called from lots of other programming languages.

>>Does it mean I have to sell OOP for procedural C or wha
Yes, unless you want to use something else, such as MFC (not free) or wxWidgets (free).

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

You don't need those loops in readb() and writeb(). All it takes is one line of code, using fread() and fwrite().

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

The only one right decidion is to overload the operator<< () and operator>> ()

Yes, that is another way to do it, but not the only way. Overloading the operators would take more processing time because the program would have to read/write the structures/classes one at a time. The way he is doing it the entire array is read/written all in one shot.

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

>>.btw,isnt there (char*)&B?
NO. B is already a pointer, so what you would create is a pointer to a pointer.

You didn't post the entire program so I can't help you more. I have no clue what Option 2 (or any other option) is.

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

I had a similar problem when I tried to install Windows 95, SP1. The sp1 install failed but could not uninstall 95. I finally found a work-around by reinstalling 95 from original CD, then Control Panel would let me uninstall it.

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

When you enter an integer the program leaves the <Enter> key '\n' in the keyboard buffer so the next getline() will just extract it instead of waiting for more keyboard input. You need to flush that '\n' out of the keyboard buffer after the cin >> age[i]; One way to do that is: cin.flush(); There is a very extensive Read Me article at the top of this c++ forum that Narue wrote which explains in more detail how to flush the input stream.

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

use regedit to see what permissions are set for the sub-key where you want to create a new key. You might not have permissions to do that.

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

Windows 7 itself contains a program that resizes the partition. If you can install Windows 7 then go to Control Panel --> System and Security --> Administrative Tools --> Computer Management --> Storage --> Disk Management Then right-click on the partition you want to shrink and click Shrink Volume. At that point I'm not certain if it was expand the c: primary partition or create yet another partition.

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

Illegal software, so its just as well you can't use it on Windows 7.

SNIP

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

Was you logged in as an Administrator when it was first installed? You may have to uninstall it then download and reinstall it again.

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

In that case you will probably have to create your own database if IC numbers and related ages. Just use a standard text editor to create it, something like this where the first column is an IC number and the second column is an age.

100   25
101   15
102   32
etc. etc

Then when the program asks for IC number, open the above file and read it until the program finds the right row.

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

didn't your instructor tell you where that IC number comes from? AFAIK there is no online database of IC numbers.

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

line 48: it is not reading the value of n from the data file. You need to put f >> n; between lines 47 and 48.


delete line 49 because that's the default when files are opened for reading.

line 50 should be this: file.read((char*)B,sizeof(books)); . The value of i is probably outside the bounds of the array anyway at that point.


line 51 is wrong. use < operator, not the <= operator.

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

make the function averate() return the average so that main() can determine whether it is pass or fail.

int average(int n)
{
   ...
   ... <snip>
   return sum/num;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Vista has a firewall, so I suspect Windows 7 does too. There was nothing mentioned about it or antivirus during installation, unless I missed it.

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

Read the file one word at a time, instead of one charcter at a time. If the word contains digits then convert the entire word to int so that "10" becomed 10. line 10 should be an array of ints, not an array of char, so that it can contain ints beyond the range normally occupied by a single char.

godsgift2dagame commented: Hey AC, thanks a lot for your help! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Okay, my very stupid question is:
Does Windows 7 still require those sluggishly slow virus programs, registry cleaners, spyware detectors/cleaners etc. etc. ???

Yes of course you will still need those. Windows 7 does not make all those antivirus programs obsolete.

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

Here is one way to do it

#include <string>
#include <sstream>
using namespace std;


int main()
{
    string s = "Adder: 4, yes";
    stringstream str(s);
    string m;
    int n;
    bool b;
    str >> m; // "Adder:"
    str >> n;  // 4
    str >> m >> m; // extract comma and the word "yes"
    if( m == "yes")
        b = true;
    else
        b = false;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your description of the problem is somewhat unclear. What does "and as how many times user" mean?

>>i have written some code, please see it and correct it :

What is wrong with it? Are you getting compiler errors? If yes, then what errors? And what compiler?

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

>>res=stmt->executeQuery("select * from test2 where english="str1"");

That has two problems:
1) "str1": you have to escape the double quotes. \"str1\"

2) The string has to be properly formatted before sending it to executeQuery() function. C++ does not automatically replace "str1" in the string with whatever word you entered.

std::string command = "select * from test2 where english=\"" + str1 + "\"";
res=stmt->executeQuery(command.c_str());
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Do you have antivirus and antispyware programs running on the computer? If not then you need to get them.

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

That problem has been here for what? 1-2 months?
Frankly I'm getting tired of waiting for threads to load.

[edit]
from pressing the post-button, to actually seeing my posted message took >20 seconds this time...

I haven't had any problems today, but yesterday morning was pretty slow.

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

I don't see anything wrong with it -- but did you post exactly the same thing that is in your program? Maybe you need to post more of the program.

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

You need to try to do that yourself. We are not here to do your homework for you. If you don't know how to do it then just read your text book that you bought when you signed up for that course.

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

lines 12 and 13. You can not allocate or delete those arrays yourself. If you want to clear out the values then just set them all to 0. memset() is the quickest way to do it, but there are other ways too. memset(series_number, 0, sizeof(series_number)); And before anybody complains, yes I know there are a few odd-ball operating systems which the memset() will not work correctly. But those are the extreme exceptions. Most, if not all, of us here on DaniWeb use either MS-Windows, *nix, or MAC.

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

There are lots of tutorials on the net, here's just one of them.

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

1) First off I assume you are an American because that's American currency you have to deal with. If not, then you might have a problem.

2) Second, I assume you know how to make change. If you owe me 25 cents and give me a 10.00 bill, how much change should I give you ? And what coins/bills should I give you ? This is a very practical problem that occurs every time you go to a store and buy something. If you can't answer that question then start preying -- err I mean start studying.

Lines 19-44 of the code you posted must be inside main() function

int main()
{
   // blabla lines 19-44
}

>>double change; // Whatever this is.

That should be initialized to the amount of change you have to give out, such as 9.75 in the example I posted above. But instead of just hard-coding some value there you will need to ask for it

cout << "Enter amount of change\n";
cin >> change;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Can you use arrays? You don't have to,

Since the average has to be done in a separate function I don't see any other way to do it but use an array. The number of scores is unknown until runtime so its not possible to just declare a bunch of integers.

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

you will need to declare an array of ints that hold the individual test scores so that they can be averaged later. Then pass that array to the function to computes the average. Declare and allocate the array between lines 11 and 12 of the code you posted. int* arry = new int[numValues]; Then delete line 15, and change line 16 to cin >> arry[count];

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

we don't do homework for you, but we will help you if you have specific questions. Post what you have tried.

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

Of course there is. Just use the stream's >> operator

int n;
ifstream in("filename.txt");
in >> n;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I made a couple attempts to install Office 97 on 64-bit Windows 7, and the both failed because some of the DLLs could not be registered. After installing the basic Office 97 from CD, I tried to install SP1, and it failed due to DLL registration problems. So I tried to uninstall it, but that failed too. Finally I reinstalled the basic Office 97 from CD then successfully uninstalled it.

If you have 64-bit Windows 7 then you will just have to upgrade to new version of Office, or get the free open source version OpenOffice. OpenOffice doesn't have all the whistles and bells that MS Office has, but if you liked Office 97 then you should not have a problem using OpenOffice.

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

line 12: its int main().

The rest is just too difficult to read because of terrible formatting. Don't be afraid to use some spaces to indent lines.

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

(Also, you can click the button to instantly jump to the first new post since your last visit)

Nice feature, but its not very reliable. Most of the time clicking New just takes me to the first or second post in the thread. I tried it with threads that had a lot of posts, and only once out of four times did it work.

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

I don't care for the "new" buttons either -- they are annoying and serve no real purpose. And when I select "Post Since Last Visit", every listed thread has a "new" button -- which should be obvious.

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

>>so it's potentially got multiple leading zeroes, which will be lost in the conversion process from int to string to int.

What's the problem with that? Integers never contain leading zeros, whether the strings have them or not.

What I would do is convert the three integers into seconds so that they can be easily compared with current time. int totalSeconds = hours * 60 * 60 + minutes* 60 + seconds; Now get a struct* tm for current and make the same calculation.

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

If you want to do it as a function then pass the string by reference

void addDoubleQuotes(std::string& str)
{
   str = '\"' + str + '\"';
}
Carrots commented: Really appreciate the help +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>output[10]=(*getwaitingtime)(proc,arr,bur,noofproc);

That is incorrect. It should be int* output = getwaitingtime(proc,arr,bur,noofproc); Then delete the declaration of output on line 69.

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

<deleted>

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

Well, what is the expected output? I can't read minds.