Murtan 317 Practically a Master Poster

Now we're getting into scope a bit (and its a big topic) but class-level variables only exist once, regardless of the number of instances of the class.

Based on your example, where you want something to persist, it could be a regular member of a class instance and the form could keep that instance around as long as the form was open, it wouldn't have to be a class-level data item. Depending on the data you want to persist, the form could just have the data instead of another class (forms are usually classes too) if that would be more convenient.

class1 and class2 normally don't have any idea that the other class exists unless they need to use the class for something. That is normally a GOOD thing. It encourages and promotes modularity in the code.

If it was necessary, class2 could access the string inside class1 if the string was declared as a public member of the class. Then class2 could reference the string via something like class1::class1string . I would personally however tend to discourage it. If you have an example where you think it might be appropriate, describe it and we'll evaluate whether or not that's a valid application and discuss alternatives.

Murtan 317 Practically a Master Poster

Yes that would be a valid example.

Another example would be a 'person' class. Each person has attributes: name, address, phone number, birthday, ...

But any two instances of 'person' are different.

Murtan 317 Practically a Master Poster

The %d in print("wait %d seconds ..." % sec) will be replaced with the numeric value of sec.

I didn't see the %s, but it is used for string values.

@Gribouillis
Shouldn't line 39 test start + 3 against the length of the list?
We're going to be referencing array elements that high.

Murtan 317 Practically a Master Poster

You're going to have to save the operands that you show the quiz taker so that you can actually perform the math to see if they give you the right answer.

Right now, in CheckAnswer, you re-generate two operands and add them together. If the user happens to have entered what the two new random number added up to, the answer is correct.

Seems like a really hard way to take a test, having the problem you're supposed to be answering hidden.

Murtan 317 Practically a Master Poster

I apparently wrote this while Ryshad was replying. He covers most of it in a more elegant fashion, but I'll post it anyway.

Local variables work like you mentioned your i did in VBA. If you declare it in a function, it goes out of scope when the function ends and is no longer available.

In C# as long as someone still has a reference to an object (or list or other collection of objects) the objects continue to persist.

If the form references a car, the form can continue to refer to that same car as long as the form exists. (Even if the user is not interacting with the form at the time.)

Regarding your form and button question, as long as the two components reference i in the same way relative to the form, they would be working with the same value.

Yes, the process of extracting data from an object in memory and writing it to an output (sometimes a file, but could be something else) is what serialization is.

The "objects can hold multiple values" is somewhat incorrect. I think what you're confused with is that there may be more than one instance of an object.

If Car is a class, then Car myCar = new Car(); declares an instance of a car that I called "myCar". I could then additionally declare Car yourCar = new Car(); . Than made 2 different, but similar 'cars'. Each car has …

Murtan 317 Practically a Master Poster

Well, ignoring that your input doesn't do much to protect the user from themselves (for example, enter "fred" when it asks for the account number and see what happens)...

Do you know in advance (or can you ask) how many they want to enter?

If you could, you could wrap the input and output in a loop. Something like the following where numberToEnter is an integer that was set prior to the loop:

BankAccount aBank(0, 0, 0);
		for (int acctindex = 0; acctindex < numberToEnter; acctindex++)
		{
			cin>>aBank;
			cout<< aBank;
			aBank.interest();
		}

That re-uses the aBank instance so at the end, you still only have one instance, but you have filled it and output from it multiple times.

Murtan 317 Practically a Master Poster

The previous posters point was that you have an IF statement on line 17...

an if is either true or false...

The 'true' clause has a return on line 19 and the 'false' clause has a return on line 23...

So in either case, the function has returned before you ever get to line 25.

There is also a lot of risk in the code as you have it written. The test on line 27 (and the related test on line 31) seem to imply that the left or right pointer could be NULL. But you have referenced the left and right pointer before the test. Based on the way you have written balanced() that would seem to be an inappropriate thing to be passing around.

Murtan 317 Practically a Master Poster

The error you were reporting was based in your original code:

if letters[x] == ' ':
        y = 0
        message_number.append(y)
        x = x+1
    if letters[x] == 'A' or 'a':
        y = 1
        message_number.append(y)
        x = x+1
    if letters[x] == 'B' or 'b':
        y = 2
        message_number.append(y)
        x = x+1

The first if test is ok, but the second test and all additional tests would always be true because they are improperly formed. What you intended to test needed to be written like this:

if letters[x] == ' ':
        y = 0
        message_number.append(y)
        x = x+1
    if letters[x] == 'A' or letters[x] == 'a':
        y = 1
        message_number.append(y)
        x = x+1
    if letters[x] == 'B' or letters[x] == 'b':
        y = 2
        message_number.append(y)
        x = x+1

But either of the two examples you were given would be a much better solution. Just wanted to make sure you understood why what you had didn't work even if it was a 'brute force' solution.

Murtan 317 Practically a Master Poster

I'm not sure what your problem is, when I compile and run it:

start
Caught One! Ex. #: 1
Caught One! Ex. #: 2
Caught a string: Value is zero
Caught One! Ex. #: 3
end

Murtan 317 Practically a Master Poster

It looks like it compiled, so the symbol was defined enough for the compiler to recognize them.

The link process is where the actual executable is built. The linker needs to match up the symbol that your main calls with the actual implementation.

You should probably add the pcsfile.cpp to the g++ command line so that it will compile and the linker will look there for symbol definitions.

There are other ways to do it, but that looks the easiest based on your description.

Murtan 317 Practically a Master Poster

Not surprisingly, but your program is doing what you told it to:

// Wait here for the user to enter a message
gets (msg);
      
while (msg != "q")
{
      /* Write out message. */
      if (write(sock, msg, sizeof(msg)) < 0)
         pdie("Writing on stream socket");
      
      /* Prepare buffer and read from it. */
      bzero(buf, sizeof(buf));
      if (read(sock, buf, BUFFER_SIZE) < 0)
         pdie("Reading stream message");
      
      printf("User %d says: %s\n", name, buf);

// Wait here for the user to enter a message
gets(msg);      
}

If you're wanting the client to be both waiting for user input and watching for messages from the server (other client) you will need to implement some form of multi-threading.

One implementation might have a thread that supports the socket and the main display of the chat. (It would add lines to the window as they were received or sent.) Another thread would support the user input, it would wait for the user to enter some data (without blocking the other thread) and then send the message the user entered to the other thread for sending to the server and adding to the chat window.

As an alternative to 'actual' multi-threading, you might be able to do something with a 'main loop' that would check for user input and check for socket data repeatedly. Something like the following:

loop forever
    if there is user input data available:
        if the user input is an 'enter':
            if the input buffer contains 'q':
                break the loop
            send the …
JimD C++ Newb commented: Multi-threading idea sounds great! +1
Murtan 317 Practically a Master Poster

So what you really want is a verification that a specific record (license) exists and you would never want anyone to be able to list or add records.

I'm not sure what resources you have available, but you could implement something like that through web service or a web page. The program would submit the license information and the service would confirm or deny the license.

You might also need to take steps to prevent someone from writing a program to attempt to test for all possible licenses. You might also want to work in a verification that the service that replied was the actual service and not a proxy that always responded with "that's a good license".

The topic is now closer to secure verification of credentials. Similar to the way users authenticate to a network. You might find more commentary and/or examples of how others are doing it if you search under that topic.

Murtan 317 Practically a Master Poster

Will the users of your application be connecting to your SQL server or is the intent for them to connect to their own server?

The following presumes they will be connecting to your server:

Hard coding the connection string makes it a little harder to find, but unless you're encrypting it somehow, it would show up if the application file was scanned for text.

Some form of light encryption along with hard coding makes the connection information non-trivial to find, but it would be even more secure if the connection the program used was NOT an administrator connection for the server.

There might be other connection types available that might not require the program to have a user name and password. (I'm thinking windows authentication, but that might not always be available or might not be a viable option.)

Murtan 317 Practically a Master Poster

Maybe you should look at the python bit-wise operators in the Python Docs

Murtan 317 Practically a Master Poster

const is a 'promise' not to change.

If you have member-functions that do not change your class (and never should) you can declare them const.

const member-functions are declared like this:

int getValue() const;

The primary purpose for const member-functions is that they are the only member-functions you can call for a const reference to that class.

Functions that need to be able to look at a class but do not need to change it should declare the parameter as a const reference.

class Sample;
int myfunc(Sample const & data)
{
//...
}

Inside myfunc (above) the only member-functions of data that can be called are the const member-functions.

Murtan 317 Practically a Master Poster

@VernonDozier
You're right (again), I missed the fact that they would all be 3's to start.

Not that it is an excuse, but my convention for TTT win checks is to check for matches against the last player to move so it wouldn't have seen the 'empty' locations.

@jesse_johnson2
Why do you maintain both g_table and mytable?

I know g_table is to display and mytable is to check for wins, but couldn't you just as easily check for wins against g_table?

Murtan 317 Practically a Master Poster

It would appear that inside move, placement is actually getting set to true when the game is 'won' but nothing is looking at placement to stop the game. The only stop case is when the board is full.

Murtan 317 Practically a Master Poster

Oh, and please:

When posting c++ code, please use c++ code tags
[code=c++] // Your code here

[/code]

Murtan 317 Practically a Master Poster

Actually, it should never get to that print line...it returns from inside all over the function. (Though I'm not sure that the returns in all of the test are required.)

Is the board required to be in an int tttb[3][3] or could we store it in an int tttb[9] and just display it in a 3 x 3 grid?

There is a lot of repeated code, creating a few more functions would clean this up a lot. The function move() is especially large.

Murtan 317 Practically a Master Poster

I think nav33n (who re-posted your code) was trying to encourage you to use code tags.

Please use code tags when posting code. For more information, click here.

When posting php code, please use php code tags
[code=php] // Your code here

[/code]

Murtan 317 Practically a Master Poster

No the problem is with python...you can't run python code without having python installed (or using the large python dll that has all of the python stuff in it.) The python code expects that all to be there.

If you want to reduce the size of what you're shipping, you need to use a language that is better able to be selective about what it has to have to run (like C).

Murtan 317 Practically a Master Poster

Where is the declaration of com_num in relation to the order function? com_num needs to be visible to any compile target that can see order.

What specifically is the compiler error?

Which is the line that generates the compiler error?

Murtan 317 Practically a Master Poster

I think the problem with the 'both' option is that when you select 'both' on the form, gender is set to '' and not to 'both'.

Murtan 317 Practically a Master Poster

Please when posting to these forums, wrap your code in code tags (like daviddoria did above).

Use either:

[code] ... [/code]
or
[code=c++]... [/code]

The second form provides for syntax highlighting and line numbers.

Murtan 317 Practically a Master Poster

If you don't intend to use any of the predefined C++ data types in your implementation, what do you propose to use?

A 6000 byte long number could be implemented, I would probably use an array with 6000 elements, but that still uses base C++ data types.

(Ignoring the fact that arbitrary precision math class is probably already available.)

I'd recommend getting over the "I don't want to use the ___, how do I do ___" mentality and focus on the objective of what you want to be done. Use the tools that are available.

If you don't have an objective that has been assigned, from school or work, then develop your own objective and assign it to yourself. This question appears to be argumentative on the surface. If you have a real-world situation that would make this line of inquiry make sense, feel free to present it.

BevoX commented: Thank you for your answer it reflects you also like to think out of the box. :) +1
Salem commented: Good +29
Murtan 317 Practically a Master Poster

My prototype (really simple -- uses 3 copies of the sample data you posted) seems to work ok. I do parse the first input file 4 times (once for each of the fields I want). Then for each remaining file, I parse it for the 4th field and output the line.

The second parse of the first file looks like this:

ifh.seek(0,0)
ostr = ""
for line in ifh:
    ostr += "%-7s" % line.strip().split()[1]
ofh.write(ostr)
ofh.write("\n")

The value 7 was determined arbitrarily and is just used to make the data look pretty. Because you have 9126 columns and each column will take up 7 spaces, each line will be 63882 characters long (seems a bit much to me, but I think it will work).

Murtan 317 Practically a Master Poster

So there will be 9126 columns of output (one extra for the headings)
and all of the values from one input file will be on one line in the output file?

Is the output file intended to be human readable or computer readable?

Human readable means you do things like try to line up decimal points and try to make the output 'pretty' when someone looks at it.

Computer readable means making it easier for the computer to extract the data.

So back to the algorithm

For the first file, we want to extract all of the fields, but can not print out the fields as we go unless we want to process through the file four times (not necessarily a bad idea, but could be inefficient).

The first line in the output file is the header followed by all of the first field values. The second output line is the header and the second field values. The third output line is the header and the third field values. The fourth line is the header and all of the fourth field values.

After the first file, the remaining files could be processed file-by-file and line-by-line:

For each remaining file
    Print the header
    for each line in the file
        print the fourth field value
    terminate the output line
Murtan 317 Practically a Master Poster

It might help if you could write (in your own words) what it is that you think you need the program to do.

The first example looks something like:

There are 10 (or N?) input files with line-oriented records.
Each input line contains 4 fields.
Generate an output file that aggregates the data from the input files.
Each output line will contain:

  • the first 3 fields from the line in the first file
  • the fourth field from each of the files

There will be one output line for each of the input lines.

My guess is that the first 3 fields identify when the sample was taken (date?) and the 4th (last?) field is the sample.

Does (or should) the program do anything to make sure that the collection date is the same in all of the files?

Would it be possible that one (or more) file(s) might not have data for a given date?

Having a better idea of what you're trying to accomplish will help us help you.

Murtan 317 Practically a Master Poster

I like using random.shuffle() on the unused cards (or deck) and then you can just pop() a random card off the unused list.

If you need to keep a used cards list, you can append the card you just got.

When it is time to shuffle again, you can refill the unused cards and random.shuffle() again. This would also work with more than one deck of cards if it was desired.

Murtan 317 Practically a Master Poster

Thanks for using [code]

[/code] tags, but your formatting could still use some work :)

If you use [code=c++] [/code] tags, the code will have line numbers and syntax highlighting.

The first section trying to validate input:

cout << "Please enter in your desired amount of lines for your"<< endl;
cin >> lines; 

if(lines>max_lines)
{
	cout<<"limit is 30 lines,please enter again\n";
    cin>>lines;
}

needs to be in a loop so it can keep checking.

For this type of application either use a do { /* ... */ } while ( test ); or a while (test) { /* ... */ } where you make sure the test passes at least once.

This is an example of the second case:

lines = 0;
while (lines < min_lines || lines > max_lines)
{
    cout << "Please enter in your desired amount of lines for your"<< endl;
    cin >> lines; 
    if (lines < min_lines)
    {
        cout << "You must have at least one line.\n";
    } else if (lines > max_lines)
    {
        cout << "You can request at most 30 lines.\n";
    }
}

(This was in the 'post' buffer while I had to go play taxi driver)

Murtan 317 Practically a Master Poster

I'm sorry, did you bother to read my post at all?

/* TAking input from user and storing it in ArrTemp array */

fgets(ArrTemp, ARR_TEMP_SIZE, stdin); 

for(iLength=0; iLength<ARR_TEMP_SIZE; iLength++)
{

/* value in ArrTemp is now stored in Dept_Name */

ArrTemp[iLength]=Dept_Name[iLength];
/* ** ** The above line assigns ArrTemp[ii] with the value from Dept_Name[ii]
   ** ** OVERWRITING the value the user just entered. */
}

You're still calling fnAddDepartment() from within fnAddDepartment, most times without closing the dept file.

You did fix the size of acLine.

You have your file reading all wrapped around input validation for the department name. You have code that does not depend on individual characters to validate inside the loop to validate individual characters.

Your file reading needs to be in a loop, but it is not.

Your if statement comparing each of the characters in the entered department name could be made more readable.

You have:

if(Dept_Name[iCount]==32 || Dept_Name[iCount]==38 || Dept_Name[iCount]==45 || 
		   (Dept_Name[iCount] >= 65 && Dept_Name[iCount] <= 90) || (Dept_Name[iCount] >= 97 && 
		    Dept_Name[iCount] <=122))

This is equivalent and much easier on the eyes:

if ( Dept_Name[iCount] == ' ' || 
     Dept_Name[iCount] == '&' ||
     Dept_Name[iCount] == '-' || 
    (Dept_Name[iCount] >= 'A' && Dept_Name[iCount] <= 'Z') ||
    (Dept_Name[iCount] >= 'a' && Dept_Name[iCount] <='z'))

Please modify the function to group more of the code together.
Before you even open the department file (why aren't you calling fnOpenFile() anyway?):

  • Prompt the user to enter the …
Murtan 317 Practically a Master Poster

problems in fnAddDepartment():

fgets(ArrTemp, ARR_TEMP_SIZE, stdin);
    for(iLength=0; iLength<ARR_TEMP_SIZE; iLength++)
    {
        ArrTemp[iLength]=Dept_Name[iLength];
    }

The first line gets input into ArrTemp, the remaining 3 lines overwrite the input with the previous name (which at the time it is used is undefined.)

You should be using looping constructs inside fnAddDepartment() and not just calling fnAddDepartment() again if you have a problem. (Mentioned in WaltP's post)

The target buffer char acLine[25]; is not big enough to handle the default case for sprintf(acLine, "-20%s %4d", Dept_Name, Dept_Code); The minimum number of characters to hold that print is 26 (with the terminating '\0'). The function you use (sprintf) will NOT check and will NOT care. There might be special cases (if Dept_Name was ever longer than 20 characters, or if Dept_Code was > 9999) where it might need more characters.

I suspect the first issue above is the one that's causing your present trouble, though the second one is problematic and the third will overwrite one byte of memory not belonging to the output string.

Murtan 317 Practically a Master Poster

That's still pretty painful to look at, maybe if your code tag worked (use [code=c++] to start it (no spaces in the tag).

You have a for loop that i think was supposed to be closed, but was not:

for(int index=5; index<10; index++)
{random_integer = (rand()%10)+1;

Did you mean to put a closing '}' on that second line?


Taking a section of code, (with the problems in it) ... putting each brace on its own line and eliminating extra braces and adding any missing braces.

if (array[0]==1)
{
    for(int index=7; index<12; index++)
    {
        random_integer = (rand()%10)+1;
    }
    enhp = enhp-random_integer;

    if(enhp< 1)
    {
        cout<<"Victory"; 
        break;
    }
    else
    {
        cout<<"You have done "<<random_integer<<" damage.\n";
    }
}
else if (array[0]==2) 
{
    cout<<"You have fled"; 
    break; 
    break;
    system("pause");
    return 0;
}
else
{
    cout<<"Invalid response, please choose again.";
    system("pause");
}

Is that closer to what you want?

Does that compile?

Murtan 317 Practically a Master Poster

I thought of a way to write your program without using the '||' operator would be to double the ifs and have 2 sections for each.

if (m == 3 && d >= 21)
    printf("\nYour star is ARIES");
if (m == 4 && d <= 19)
    printf("\nYour star is ARIES");

See no '||' but it will be longer and return the symbol twice.

I just thought of another alternative (I'm full of good ideas today :) ):

if you did something like:

/* Put the month and day together as MMDD in a single int */
int birthmd = m * 100 + d;
if (birthmd >= 321 && birthmd <= 419)
    printf("\nYour star is ARIES");

Even cleaner and still no pesky '||'

Murtan 317 Practically a Master Poster

Actually, that code tag message was intended as a reply for yabuki

But if you're not posting your code with code tags, feel free to use them :)

Murtan 317 Practically a Master Poster

You already have a 'global' (ok so it is local to the class, but all of the class methods can see it) data area defined. See this section under private in your class:

private:
	double average;
	string courseName [4];
	char  gradeLetter [4];
	int gradePoint [4];

The only reason you aren't sharing the data is because you hide it by re-declaring the same variables inside your functions:

Here

void displayMessage ()
	{
		char  gradeLetter [4] = {};
		string courseName [4] = {""};

and here

double getAverage ()
	{
		int gradePoint [4] = {};
		char  gradeLetter [4] = {};
		double average = 0.0;

You can just comment out (or delete) the declarations under each function and they will use the class data, sharing it between them.

I noticed why you aren't having to enter four grades for each class, it is the break inside the for (y ... loop.

I might ask why you even have that loop anyway. Why not just do something like the following? (I have commented out your code where it is not needed or where I have modified it.)

void displayMessage ()
	{
		//char  gradeLetter [4] = {};
		//string courseName [4] = {""};

		for ( int x = 0; x < 4; x++ )
		{
			cout<< "Please enter name of course:";
			getline(cin, courseName [x]);

			//for ( int y = 0; y < 4; y++ )
			//{
			cout<< "Enter grade recieved:";
			//cin>> gradeLetter [y];
			cin>> gradeLetter [x];
			//	break;
			//}
			cin.ignore …
VernonDozier commented: Good advice. +11
Murtan 317 Practically a Master Poster

I don't think I can be much more blatant.

When you type:
[code=c] int main() { printf("Hello, World\n"); return 0; }

[/code]

It looks like this when you post it:

int main() {
    printf("Hello, World\n");
    return 0;
}

The article that talks about it is at http://www.daniweb.com/forums/thread93280.html

Murtan 317 Practically a Master Poster

That's very pretty code, but it should have been posted using code tags.

When posting c code, please use c code tags
[code=c] /* Your code here */

[/code]

And logically, the if statements you have don't meet the needed criteria.

For example your first if: if ((d>=21 || d<=19) && (m==3 || m==4)) Is valid for the following dates:
3/1 to 3/19, 3/21 to 3/31, 4/1 to 4/19, and 4/21 to 4/30

(blatantly borrowed from Wikipedia)

Under the tropical zodiac, the Sun is in Aries roughly from March 21 to April 19, by definition beginning at vernal equinox.

Murtan 317 Practically a Master Poster

When you run the code, are you still having to put the grades in 4 times or did you fix that?

Could you post your new code?

Murtan 317 Practically a Master Poster

Quoting ... again:

In elapsed(), realize that t1 is the 'start' time and t2 is the 'end' time, and think back to your basic math:

  • How much time has elapsed between 08:45 and 10:15?
  • How did you figure out that it was 01:30?
  • Make the computer do that...

You appear to have the same code in elapsed. You initialize duration to zero, compare it to t1 and t2 without doing anything with either value and return.

Perform the calculation suggested in the quote above using the hours and minutes from t1 and t2 and THEN initialize duration from the calculated value.

Murtan 317 Practically a Master Poster

Why are you trying to re-declare h inside the if statement?

if ( int h > 10)

should be:

if (h > 10)

Which is what I typed in my example...are you trying to break your code on purpose?

Where's the code to print the ':'?

Where's the code to support minutes?

Murtan 317 Practically a Master Poster

AND and OR are 2 similar but different constructs.

month = 3 && month == 4
Is an impossibility, it will NEVER happen

month == 3 || month == 4
happens for months 3 and 4

Murtan 317 Practically a Master Poster

Rephrasing one of your if statements into english:

if (d>=21 && d<=19 && m==3 && m==4)

That reads: If the day of the month is both more than or equal to 21 and also less than or equal to 19 {this is impossibility one} and the month number is 3 and the month number is 4 {two}

What you want is something like:

If the month number is 3 and the day of the month is the 21st or later, OR the month number is 4 and the day of the month is the 19th or earlier

so you need to end up with a test that looks something like the following:

if ( ( ___ && ___ ) || ( ____ && ___ ) )
Murtan 317 Practically a Master Poster

Once you have both of those, you can use the two numbers to calculate the total weight of the widgets.

And if you know how much all the widgets weigh and how much a single widget weighs (and at this point you would know both of those) you can calculate how many widgets must be on the pallet.

Murtan 317 Practically a Master Poster

Your class has space for 4 class names and 4 grades.

But when you accept input from the user, you read a class name and then 4 grades for that class.

Then you read the next class name and 4 grades for the second class. (But you store the 4 grades from the second class where the first class did so you lost the 4 grades from the first class.)

Is your intent 4 classes with 1 grade each, or 4 classes with 4 grades each?

Murtan 317 Practically a Master Poster

ok you could make that work, but you forgot to print the m and h...and you should probably print the hours first.

if (h > 10) {
    cout << h;
} else {
    cout << '0' << h;
}

Remember to put the punctuation in as well.

Murtan 317 Practically a Master Poster

Putting code in headers is generally bad form....if you include that same header in more than one file in a compilation unit you get duplicate symbols.

The original layout of the files should have worked, did you include myfile.obj or myfile.o when you compiled main.c?

Murtan 317 Practically a Master Poster

No.

h ends up zero and m ends up being whatever h was * 60

Now that I think about it, why does display1Time even need h and m, aren't the hours and minutes in Mytime?

The tens and ones hint was to do something like this:

int tenmin = t.mins / 10;
int onemin = t.mins % 10;

When the time is less than ten minutes after the hour tenmin will contain zero, but when you print both numbers together you get the type of display you want. If the time is ten or more minutes after the hour, you wouldn't HAVE to split the number like that, but it will still work if you print both numbers together.

Murtan 317 Practically a Master Poster

Line 58: else if (m > 60) should compare m > 59

You have made no additional effort on display1Time() or elapsed() and I have already given you suggestions for those:

in displayTime() you need to do something so that 5 hours and 5 minutes displays as 05:05 and not 5:5

Maybe you should print the tens digit and the ones digit of each number. If you don't understand that, you could look into "iomanip, setfill and setw".

and

In elapsed(), realize that t1 is the 'start' time and t2 is the 'end' time, and think back to your basic math:

  • How much time has elapsed between 08:45 and 10:15?
  • How did you figure out that it was 01:30?
  • Make the computer do that...
Murtan 317 Practically a Master Poster

There's no real difference in how the symbol is treated other than the fact that the compiler would allow you to modify argv in the second example. (Not that modifying argv is a good idea.)

The first example should complain if you tried to do argv++ but the second example should happily let you do it -- even though its a bad idea.