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

Since Dt is passed by value then it means the entire structure is pushed onto the stack (in most implementations) when Function1 is called. That's what pass by value means.

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

>>My confusion is in myFunc1. What is happening? If you pass by value, exactly what value
>> does Date dt contain (a pointer?)? Is Date d a local copy of Date dt?

Yes. structures (classes) can be passed by value just like POD (plain-old-data) types. The ocmpiler makes a copy of the structure and puts that into the parameter of the called function. Whatever changes the called function makes to the structure or class are NOT reflected in the copy of the calling function.

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

>>what dose <snip> mean
It just means I left out code, like snipping with a pair of sizzers.

>>how do i input in the test scores and points?
Just like you did all the others. Look to see what you already did and you will have the answer.

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

>>but how do i use that to call the test scores later and display them in the for loop thing?
Just like you did with the other class variables

for(int i = 0; i < number_class_objects; i++)
{
    cout << students[i].grades;
}

>>and alo how would i stop the for loop if i ran out of names before i got to twenty?
There are lots of ways to do that. One way is to ask the question at the end of the loop.

for(int i = 0; i < maxStudents; i++)
{
   <snip>
   char answer;
   cout << "Enter another student info (y or n) ?\n";
   cin >> answer;
   if(answer == 'N' || answer == 'n')
       break;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 44: you have changed months[] array so that month 0 does not really exist -- Jan is in month[1]. Therefore you have to change line 44 (and other lines like it) to just use mm, not mm-1. if( dd < 1 || dd > months[mm] ) >>else if( dd > months[2] )
You also have to check if mm == 2 else if( mm == 2 && dd > months[2] ) Or just simply else if( dd > months[mm] ) >>if(leapyear(year)&& mm == 2 &&(yyyy % 4) == 0 && (yyyy % 100 != 0) || (yyyy % 400 == 0))
That is too late because of the previous line shown above. You have to make the adjustment before checking if dd > months[mm].

>> else
>> {
>> months[2] = 29;

line 66: Nope. That's wrong. Just because previous tests failed doesn't mean its a leap year. Actually just the opposite -- if leapyear() fails then its NOT a leap year for months[2] should be 28, not 29.

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

convert both dates to integer then all you have to compare is one simple integer. You can use the mktime() function in time.h to help you out. For example, 1 Jan 2008 is converted like this:

int main()
{
    struct tm tm;
    time_t t1;
    memset(&tm,0,sizeof(struct tm));
    tm.tm_mday = 1;
    tm.tm_mon = 0; // 0 = Jan, 1 = Feb etc.
    tm.tm_year = 2008 - 1900;
    t1 = mktime(&tm);
    cout << t1 << "\n";

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

Please repost entire program because I don't know what changes you may have made since last post.

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

Simple:

class Student
{
private:
	string firstName;
	string lastName;
	int idNum;
   int score;
   int pointes;

	
public:
<snip>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>when we talking about divisible by 4 or by 100 or by 400 in my mind it is
yyyy / 4 == 0 is not what that means. If it was then there would be no leap years since year 4 AD! Think about it: 5 / 4 = 1, 6 / 4 = 1 and 7 / 4 = 1.

The mod operator returns the remainder after division. so 2004 % 4 is the same as 2004/4 with a remainder of 0. Integer division always drops all fractions, so to get the fraction you need to use the mod operator or do floating point (and much slower to boot) division.

To find out if a year is a leap year or not you need to know if the remainder after division is 0 or not. You can't do that with normal integer division such as 2004/4.

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

>>if you could write the code you would have my undying gratitude
I will after you deposite $10,000.00 USD in my paypal account.

DaniWeb is not a sofware whorehouse. We help, you write.

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

I like my quote a lot better because its much shorter and doesn't contain so much glbbledygook :)

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

Or this: and leave all the rest of your program as it is.

char *sentence1="There Once was a Man called Reg";
	char *sentence2="Who Went with a Girl in a Hedge";
	char *sentence3="Along came his wife";
	char *sentence4="With a big Carving Knife";
	char *sentence5="And cut off his meat and two veg";
    char sentence[1024] = {0};

>>sentence1[rand()%5]
what is that supposed to be? All that will give you is one character from sentence1. It will not give you the entire sentence.

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

lines 10-15 are wrong. Here is how to declare that array of strings

char *sentences[] = {
"String1",
"String2",
// etc etc
};

and delete lines 19 - 32 because they are all wrong.

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

Yes there was.

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

could this be the next 2 girls one cup!?!?!??!?!
dibs on first youtube live skinning reaction video!

jk, live skinning animals is horrible. do on to others as you would have them do on to you. i sure wouldn't want to be skinned alive!!!!

Neither would I, but I understand American Indians did it -- hang people upside down, strip them naked, then skin them from heal down. Horrible death.

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

>>However increased awareness might trigger a snowball effect (one day, one day!)
Just wishful thinking on your part. There are alread a large number of animal rights organizations around the world, yet China is apparently ignoring all of them.

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

lines 8 and 13 must have identical parameter types. Normall do not use cin in the set functions. Put all cin statements in the main() or whereever but not in the set functions. In the set functions just set the class variable to the parameter

void setName(string name)
    {
         
         this->name = name;
         
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Trying to Find the imp in the system that has been Needlessly Capitalizing Words and stealing Punctuation

Whats Up With You

The imp in the system was a filter that converted all uppercase posts to lower case with the first letter capital. After some discussion I think Dani has disabled that feature.

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

>>And through this reduction in ignorance, these atrocities may cease
It will do nothing for that because the people who need to be informed have no intention of stopping. Its like the war in arabian countries like iraq -- they have been at war for thousands of years and will be at war with each other forever. China will probably never ever change its ways without some major change in government. And, unfortunately, that isn't likely to happen in the next 100 or so years.

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

by vector do you mean a character array ? Such as char data[255]; Use the FILE and associated functions located in stdio.h to read and write files. Here is a tutorial.

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

create two variables called heavest and lightest. Then create a loop like you did on line 33, but instead of adding up everything keep track of the heavest and lightest values. For example:

if( a[i] > heavest)
   heavest = a[i];

and do the same for lightest except of course your have to use < operator instead of >.

Be sure to initailize both of the variables to a[0] before starting the loop.

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

how it looks is not relevant. Does it work the way you want it to work? Yes -- then its ok. No then you need to do more work.

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

if( year % 4 == 0) Most of the time if that is true then year is a leap year. 2001 is NOT a leap year because it is not evenly divisible by 4. 2004 IS a leap year because it is evenly divible by 4.

A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400.

Thus years such as 1996, 1992, 1988 and so on are leap years because they are divisible by 4 but not by 100. For century years, the 400 rule is important. Thus, century years 1900, 1800 and 1700 while all still divisible by 4 are also exactly divisible by 100. As they are not further divisible by 400, they are not leap years.

http://www.dataip.co.uk/Reference/LeapYear.php

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

since the array is global it isn't necessary to pass it as a parameter.

line 16: just make that a function call reading_data_into_array(); line 21: make that a void function because it isn't necessary to return anything and delete the parameter because the array is global..

line 24: you need a while loop to read each of the numbers into the array

int i = 0;
while( infile >> a[i] )
    ++i;

line 25: delete it.

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

you have to flush the input keyboard buffer of the '\n' after each numeric input

cout << "Enter the players number :";
        cin >> player[i].number;
        cin.ignore();
        cout << "Enter the players points :";
        cin >> player[i].points;
        cin.ignore();

line 34: that's an infinite loop because 0 is ALWAYS less than SIZE ! Correction here: for (int i = 0; i < SIZE; i++)

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

>>So I know how to delete a descriptor from an array,
define descriptor

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

line 77: you can't call a constructor after instantiating the class objest (line 56). After that you must call the set functions.

students[i].setName(FirstName, LastName);
students[i].setID(id);

Make the score and point values part of the class so that you can easily match them up with the student.

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

Hey It works!!! It's so nice when a computer does what you tell it to.

Thanks for your help.

The computer was doing exactly what you told it to do. Your problem was that you told it to do the wrong thing :)

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

EDIT: I've tried to learn some debugging, and it appears that vectorOfInformation don't get filled with any information! It's empty after the while(getline())-loop, which should append all the lines in the textfile to it.

I use the same compiler, and that's why the program doesn't crash for you. Put a check after the open statement to see if the file was actually opened. I had that problem once and had to change the location of the file.

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

In some cases that's true -- I also like some infomercials.

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

>>char play_again = '\n'
make that = 'y' instead of '\n' because '\n' doesn't make sense

>>while(play_again == '\n')
check for 'y' instead of '\n'

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

learn to use you compiler's debugger and step through the program one line at a time so that you can see what its doing.

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

>>correct = compareNumbers[user, lottery];

First, compareNumbers is uninitialized, which is why you get the core dump.

Second, what exactly is that line doing? compareNumbers is a simple integer, so how can you possibly use it like that ???? user and lottery are both int arrays. That doesn't make sense, but the compiler doesn't complain.

I've never seen anything like that before -- what is it doing?

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

I compiled your program with VC++ 2008 Express and it crashes bigtime. I don't know what compiler you are using but I'd suggest you get a different compiler. The file I used contain just one line that you had in comments at the top of your program -- (2344)(Arne Kristoffer)(Abc 3) It crashes here:

for (int x = 0; x != vec.size(); x++)
		{
			vec[x].erase(vec[x].length()-1);
			vec[x].erase(0,1);

		}

If you can't take the time to use a decent compiler with a great debugger then I don't have the time to do your debugging for you any more.

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

Unlike *nix you can install the source code anywhere you like.

I downloaded mysql++-3.0.2.tar.gz and used WinZip to decompress it. In the uncompressed directory you will see volders for VC2003 and VC2005. Just fire up your compiler and select File --> Open --> Project Solution. Navigate to whereever you installed MySql++ and select mysql++.sln

I guess you have to have MySql server installed because I can't compile it the VC++ 2008 Express. mysql_version.h is not included in the above download.

VernonDozier commented: Thanks. +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why does months[] have 14 elements but you only use the first 12? Feb 29 has nothing to do with the number of months in a year.

and not sure if the line: if( dd < 1 || dd > months[dd-1] ) work correctely??

That line is incorrect. it should be using mm to index into months[], not dd

if( dd < 1 || dd > months[mm-1] )

Now think about that that is doing. mm is a month number from 1 - 12. But the number of days in January is represented by months[0], not months[1]. So to get to the correct index number on months[] you have to convert mm to be 0-based to that Jan = 0, Feb = 1, ... Dec = 11.

The other part of that equiation -- [icode]dd > months[mm-1][/icode -- is checking if the dd is greater than the number of days in the given month.

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

lines 25 and 144 do not match.

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

I'm using Vista Home Premium and get the error Web Page Cannot be Found. Maybe its one of those Vista things.

thunderstorm98 commented: Funny Statement.. +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I still can't see the code you wrote. If you want us to help you then you have to post code because we can't just guess what you did.

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

I think you need to learn how to use your compiler's debugger so that you don't have to ask us to do your debugging for you. If you used your compiler's debugger you would quickly find that the problem now is at line 52.

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

It actually gives me a little pleasure that after two years I finally know something that you didn't ;)

LOL. There's lots of things I don't know -- for example I don't know diddly squat about web programming.

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

just found this searching google .
http://www.fixmyxp.com/content/view/187/129/

link doesn't work. But OP's intentions don't sound honorable to me.

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

Yes, he saw that. He also explained your problem for you, so that you can come up with a solution yourself.
.

he :icon_eek: Aia's avatar looks female to me :)

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

Probably if you can find a web service other than IIS for MS-Windows. I thought Apache only ran on *nix, but could be wrong about that.

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

lines 10-13: not needed. If you want a vector to start with a specific size then just call its resize() method

line 42: str is an empty string, so attempting to access anything beyone str[0] is an error.

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

You are asking some very basic questions that most tutorials can probably answer, such as this one. Start at the top of that tutorial and take your time reading through it.

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

I would work though the tutorial first to find out how things go. Then it will be easier to understand QT.

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

It means that >> is a cin operator....
okay..
>> and we can also initialize count=0 in for loop as well na....
>>and what abt (count<max_num) in for loop..

Are you asking or telling? >> is used by cin too but it also applies to all other input streams in <fstream> and <iostream>

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

>>Why there we initialize array to 0
To insure all array elements have a known initial value. May programs have gone sour because of uninitialized variables. Its a good habbit to initialize all variables and arrays when they are declared.

>>and then whats the purpose of >> operater
That is the file extraction operator, it reads one item from the file into the specified array element.

>>Secondly in FOR-LOOP can we use two variables; like there we used one variable "count"
>>in initialization and in increament, while in conditional part, we used "infile>>sort
>>[]",which doesnt invole count

Yes, you can have any number of statements there. The infile >> sort[count] just says while not end-of-file and extracts another item from the file and puts it into the array

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

Or a nuclear war.