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

I caught that typo error and corrected it. But I'm glad you know what I intended to write :)

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

had a influencial programming professor (Dept. Chair, actually) who would say:"Indenting? Nah, that's a waste of time-- I don't care if its all pretty. It just matters that it runs."

Tell him he is an idot and has no business trying to teach anything but maybe a basket weaving course and he may not even be qualified to teach that. I would also report him to the head of the department ---- oops! he is the deparment head? Then I would transfer to a different university where they have competent instructors.

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

The number of braces in printShipPos() looks ok to me.

srand((unsigned)time(0));   //RNG
    float shipPos; 
    for(int index=0; index<1; index++){

two comments: (1) srand() should only be called once throught the lifetime of the program. Best place to put it is near the beginning of main() function.

(2) I hope you realize that loop will be executed only once. If you do then there really is no point to the loop.

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

very similar to the code I already posted. Assume you have a Read button Note: there are other c++ ways to convert from std::string to ints, what I show below works most of the time but will not catch errors in the data read from the xls file or integer overflow problems.

void OnButtonRead()
{
    // do something to read the xls file into member 
    // this assumes the data is read into std::string object
    string add1 = ??? // read xls
    string add2 = ??? // read from xls
    m_add1 = atoi(add1.c_str());
    m_add2 = atoi(add2.c_str());
    m_sum = m_add1 + m_add2;
    UpdateData(FALSE);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

in the OnButtonAdd() event handler for the button
1. assume m_sum, m_add1 and m_add2 are integer class member variables which were defined using ClassWizard (VC++ 6.0 compiler), just call UpdateData() after setting m_sum = m_add1 + m_add2.

void OnButtonAdd()
{
   // move window text into member variables
   UpdateData(TRUE); 
   m_sum = m_dat1 + m_data2;
   // move data member variables back to windows
   UpdateData(FALSE);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>char ArraySize =[11][25];
This is incorrect syntax.

>>strcpy(hold, arrNames[j]);
variable hold is defined to be a single char. You can not copy a string to a char variable.

>>void Quit(char [11][25]);
Function prototype and actual function are different. your compiler will produce unresolved externals error.

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

Paradox: didn't you read this thread that you started a couple days ago ?? The question was answered there, complete with examples.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
grosspay = (hours * rate);
if (hours > 40)
      grosspay = ((hours - 40) * rate * 1.5) + (40 * rate);
if (hours > 60)
      grosspay = ((hours - 60) * rate * 2) + (20 * rate * 1.5) +(40 * rate);

The if condition statements are backwards. First check for over 60 else if not over 60 check for over 40. The way you have it, over 60 will get both calculations.

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

save the paper for NEXT year

I have never seen anyone actually do that in my lifetime. Remove the paper neatly from the box, fold it up nice, then toss it into the trash can.:mrgreen:

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

first you need to know what programming language was it written in and for what operating system -- assembly, C, C++, BASIC, VB, pearl, pascal, or any one of hundreds of others. If you don't know, then please post some of the code and someone may recognize the language.

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

what is it supposed to do? I pressed it and it seems to do nothing except highlight the button.

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

According to this article published just last year. It would appear that strict gun control laws does nothing more than increase violent crimes, most likely because criminals could care less about those laws and leave the average good citizen wide open for victimization by criminals.

So we have two countries, both with strict gun control yet one, England, has a hihger violent crime rate than the U.S. while one, Singapore has a far lower crime rate than the U.S. One, England without the death penalty, and one, Singapore, with the death penalty.

<snip>

England and Wales have the highest crime rate among the world’s leading economies, according to a new report by the United Nations.
The survey, which is likely to prove embarrassing to David Blunkett, the Home Secretary. shows that people are more likely to be mugged, burgled, robbed or assaulted here than in America, Germany, Russia, South Africa or any other of the world’s 20 largest nations. Only the Dominican Republic, New Zealand and Finland have higher crime rates than England and Wales.
Crime in Japan is soaring while the arrest rate of culprits is dropping, a report has shown.

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

depends on the operating system. MS-Windows will not permit a program access to the hardware ports directly, and neither will *nix running on intell-based computers unless you are writing a kernel-level device driver. In MS-DOS 6.X and earlier I've used int 16 but never accessed the ports directly.

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

Here is a solution using inline assembly in c program

#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
	char s1[] = "Hello World";
	char s2[255] = {0};
	int len = 0;
	_asm
	{
		push	esi
		push	edi
		lea		esi,s1
		lea		edi,s2
		; get length of string s1
		xor		eax,eax	
		mov		ecx,0ffh ; max length of string ?
		repnz	cmpsb	  ;locate 0 byte, if it exists
		jnz		l1		; oops! not a null terminated string
		not		ecx		; make it an integer
		and		ecx,0000000ffh ; mask off high dword
		lea		edi,[len]	; save for output later
		mov		[edi],cx	; 

		;
		;
		; reverse the string
		lea		edi,s2		; set up registers for moving string
		lea		esi,s1
		add		esi,ecx
		dec		esi
		dec		esi
		xor		eax,eax
l2:		; move each byte from ds:esi to es:edi in reverse order
		; would be nice if we could use rep movsb, but we can't
		; so have to do it the lard way.
		mov		al,[esi]
		mov		[edi],al
		inc		edi
		dec		esi
		loopnz	l2
		mov		[edi],0



	l1: nop ; not found
		pop		edi
		pop		esi


	}
	cout << len << endl;
	cout << s2 << endl;
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are probably using controls and dialogs that are not supported in Win98. Read the system requirements in MSDN for the dialogs/functions you are using. For example, is your dialog using UNICODE strings? If it is, then it won't work in Win98 because that os does not support UNICODE.

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

Another way to do toupper without a function (just subtract 32 from the lower-case letter)

if( letters[i] >= 'a' && letters[i] <= 'z')
   letters[i] -= 32;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First, you don't need to load the dlls. just include windows.h and you will have access to most of the functions you need

#include <windows.h>
// your code here

Which functions do you need? I don't know, sorry.

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

something like this perhaps?

char i;
 
for (i = 'a' ; i <= 'Z'; i++)
{
printf("Char: %c was found %d times", i, count[i]);
 
}

I didn't test it, but it should work fine!

Yes, something like that, but a little different. because it must also count the number of times non-alpha characters were entered

char i;
 
for (i = 0 ; i < 255; i++)
{
    if( count[i] > 0)
         printf("Char: %c was found %d times", count[i], count[i]);
 
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here's a working example of how to reverse a string using a function. Hope this helps, good luck!

#include <iostream>

using namespace std;

void ReverseString(char string1[], char reversed[]);

int main()
{
    const int MAX = 80;
    char string1[MAX];
    char reversed[MAX];
    cout << "Enter your string: ";
    cin.get(string1,MAX);

    ReverseString(string1, reversed);

    return 0;
}

void ReverseString(char string1[], char reversed[])
{
    int length = strlen(string1);

    for (int i=length-1, j=0; i>=0; i--, j++)
        reversed[j] = string1[i];

    for (i=0; i<length; i++)
        cout << reversed[i];

    cout << endl;
}

You really should compile and test your code before posting. It contains several bugs that may just confuse the OP.

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

Thanks,
You guys are a great help. I was not supposed to use any library functions, that eliminated the uppercase function. Also the array was to have a maximum of 96 characters only.

JONN.

The array of 96 characters is a limit on the number of characters you should enter from the keyboard. You need a another integer array to count the number of times a character was entered -- for example how may times did you enter the letter 'A', and how many times did you enter '1' ? Your program does not currently tell you that.

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

>>But if I run the program it still works.
You are not running the program that you think you are unless you are using a really really old and ancient compiler. None of the compilers I have seen in recent years will produce an executable program when there are compiler errors.

>>When I try to compile the code below I get an error saying: error C2065: 'file' : undeclared identifier.

Tis true -- that variable only has scope within the try block where it was declared. If you want to use it later you have to declare the variable above the try block.

I see no advantage of that try block anyway, but possibly your program is not finished yet???

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

may4life -- it may be a somewhat working solution (there is at least one bug I can spot), but much too long and too difficult. It can be greatly simplified by using an array of 255 then using the letter entered as the index into the array. That eleminates that huge switch statement.

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

Please use code tags when posting code. Its not all that difficult and makes your post look a whole lot better.

>>for(index = 0; index < DECLARED_SIZE; ++index)letters[index] = 0;
This line is not necessary if you declare the array with an initializer, like this:

char letters[DECLARED_SIZE] = {0}, next;

Isn't function uppercase() supposed to convert the array to all upper case characters? Then why did you make it so difficult? It can be done in only a couple lines of code

void uppercase(char letters[])
{
       int k;
       for (k = 0; letters[k] != '#'; k++)
               letters[k] = toupper(letters[k]);
}

I need a code that keeps a count of each letter entered, and any a count for all other non-letter symbols entered.

The code you posted does not do that.

You really do not need array letters at all, unless required by your instructor. what you need is an array of integers that keeps a count of the number of times a letter is entered. After you enter a character from the keyboard (or a file), convert the character to upper case then increment the array element (see my previous post for example).

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

Where the heck is the edit button nowadays? I got it for this and other posts, but not my post above :S

I think you only have 30 minutes to edit a post.

As for the problem: I don't know the answer. If you first move the nerd to the office, that leave the bully and apple together on the playground -- that's ok. But I don't know how to solve the problem at that point. Do you ? If not, please repost this in the Geek's Lounge and hopefully some (or lots) of people can help solve it.

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

you have already coded all the required overload operators. In main() just use them like this

int main()
{

   Complex x;
   Complex y( 4.3, 8.2 );
   Complex z( 3.3, 1.1 );
   cout << "x: " << x;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Do the variable names survive the compilation process? If someone was to read compiled code in raw memory, would they see the variable names?
No. Compiled porgrams know nothing about variable names -- they are all nothing more than addresses. Variable names are only for you, the human programmer.


>>Also, the process of taking one variable name in a public funtion, and then assigning it's value to a private variable seems redundant and a bit convoluted to me

This has the advantage of allowing only one place in the program to change the value of a class variable. If you later want to change the way the variable is used the programmer has to make the change in only one place.

>>Also the concept of 'constant functions" seems contrived. What is really happening with that?

const tells you and the compiler that the object can not be changed or that the const function is not going to change any data objects of the class. It has no affect on the code itself, but is a retraint on you, the programmer, not to mess around with class objects -- class objects are read-only. Also, a const class method can only call other const methods of the same class.

>>If some program went awry, wouldn't that 'constant" piece of code get "stepped on"? After all, both are just memory locations! I don't fully appeciate the difference

Const is a compile-time restriction. It has …

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

if you posted the wrong code then you need to post the correct code. We don't care if the code you posted doesn't work. Post the code you know how to do then we can talk about how to complete the assignment.

by "mark" do you mean "grade" ?

>>the interval between identical marks
what exactly does that mean?

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

Does anyone know how to writea program to print

Yup. Next question :)

create two loops -- outer loops counts backwards from 10 to 1, the inner loop counts forwards from 1 to the value of the outer loop counter. Then print the value of the inner loop counter.

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

you will have to add a little code to getOvertimePay() to make that check. First, check for over 60 hours. If its over 60 then calculate 2.0 rate. If not over 60 then do what the function does now -- you don't need to change that part. Something like this:

Is hoursWorked > 60
{
    overtimePay = XXX
}
Otherwise is hoursWorked > 40
{
    overtimePay = XXX
}
else
{

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

No -- that information is not saved in the FILE structure.

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

use Explorer to delete the project directories, then in VC++ 2005 IDE Start page click on the project name. You will get an option to remove the project.

If there's a quicker method I sure would like to know too.

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

sppt to be slpping but i rdy am :O

I do not have the slightest idea what you wrote. Please write in plain English language so that eveyone can understand you. Despite what you might think this is not a chat room.

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

Umm *Looks to the left*.... *Nods head shakes head questions...?*

If you didt get that message then that means Confused

why answer this year-old thread? I doubt anyone really cares any more. I'm going to close it

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

One very good free compiler Dev-C++ . That is probably the easiest one for newbes to use. Once you get your feet wet you can also get free the Microsoft VC++ 2005 Express compiler It is a little more complicated then Dev-C++

[edit]Ohhhh! Ahhhh! I see Bloodshet.net revamped their site -- much prettier now and appears to be a lot easier to navigate. If you have not seen it then you should visit and see the new and improved web pages[/edit]

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

Yes, programming books are terribly expensive. If you want to learn how to write C or C++ programs then be prepared to do lots of reading, many many hours of practice, and spend quite a few $$. You may not have to buy all those books -- get the first two on the list, study them first, then in a few months you might be ready for the others. You might be able to find some of those books at your local library, others you might be able to find used copies at discounted prices at used book stores or online at www.amazon.com.

If you think the information in that link about starting C and C++ is too confisuing for you, then you may not be ready yet to begin studying programming. Wait a year or so then try again when you are a little more mature (assuming you aren't already). Often a year makes a big difference in young minds.

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

Well I am going to get the 7 in 1 c++ for dummies book And read it then I will confim with you guys for the next step ok? We will all share the $$$

Bad book -- don't waste your time and $$ on it. Read this thread for lots of good advice

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

Where's the global instance of charge ? I can't seem to find it...

I thought it was just above main(), but I don't see it now. So maybe I was seeing things?

Sorry Joe, I accidentally edited your post instead of creating a new one. But fixed it now.

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

You mean the 80 dollar one? Woah... Going to have to sell my wow account for that one and btw I dont understand ANY of it So I guess I am off to go get me a C++ book o_O

:mrgreen: :mrgreen: Told you so.

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

variable charge is declared both as a global and as a local variable inside main(). Delete the variable in main() because it hides the global.

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

please do not wrap the program requirements in code tags because it is difficult to read with all of it on the same line.

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

What operating system are you using? That is a linux function and not supported in MS-Windows. But if you are using linux then I don't know the answer because I don't have a linux computer available to me where I am at.

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

>>*pch = ch[0];
Example 1-1

Above line is incorrect because pointer pch is uninitialized.

>>ptr = &n[0];
Example 1-3.

This can also be simplified like below: The & operator is not necessary.
ptr = n;

>>ca[3] = '\0';
Figure 2-1
The above is wrong because array ca only has 3 elements, not 4.

>>ptr = &text[0]; // not recommen
Example 2-2

Why is this not recommended? You did not explain that statement.

Example 2-3: I disagree -- it seems to add a lot more complexity to such a simple and elementry operation. The example in Example 2-2 works just find and is the one most frequently used.

>>ptr = (char *)malloc(6);]
Code 2-1
malloc() should not be typecase in C, but is required in C++

Example 3-1 is a very good example of why not to use strcpy() -- because it can easily cause buffer overrun and scribble all over the program's memory.

>> ptr = (char **)malloc(rows * (sizeof *ptr)); // allocate room for rows
Code 3-1
sizeof(*ptr) will result most likely always return 1 becuase sizeof(char) is always 1. This is clearly not what you are attempting to do. The program needs to allocate room for rows number of pointers, like this:

ptr = malloc(rows * sizeof (char*)) // allocate room for rows

>> ptr = (char *)malloc(strlen(word) + 1 * (sizeof **ptr));

Same problem as …

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

I don't either, but they are callet Internet Sniffer, or Network Sniffer. Here is where to start your research

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

there are only 255 possibilities, so just make an int array 255 and use the character as the index

int count[255] = {0}
char c = 'A';
++count[c];

when done the elemenets of count > 0 is the frequency you want.

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

packets of what? If your program is doing the sending, then yes

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
char filter[] = "abcdefghijklmnopqrstuvwxyz  0123456789 . _ - ! ? + :";
char text[] = "abcöË@#*&|}";

char buf[255] = {0};
char *ptr1 = buf;
char *ptr2 = text;
for(int i = 0; text[i] != 0; i++)
{
  // if the ith character in text is contained in filter
  // then add it to buf array.
  if( strchr(filter,text[i] != 0)
       *ptr1++ = text[i];
}
// now buf contains all the valid characters
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to post your code that does not work. One way to do it is use strpbrk() function

char text[] = "Hello World";
// filter out 'H' and 'W' letters
char filter[] = "HW";

char *p = strpbrk(text,filter);
// if p == NULL then text[] does not contain any characters
// in filter[]
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use unsigned long intead of int. But first check for the maximum value for your compiler in the file limits.h. The maximum value for an unsigned long on my compiler is 4,294,967,295 -- slightly smaller than the value you want. You may have to go with a 64-bit integer, longlong on some compilers and __int64 on others.

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

Of course if you are curious enough you could ask google your question and study the links it gives you. I found at least a half-dozen articles in just a few seconds.

Most universities officer course in operating systems. You might take one of those courses, but you will need to meed the prerequisits first.

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

I am running 64-bit Fedora core 5 and attempted to download core 6. The download (FireFox browser) took about 8 hours and when done the file could not be saved :mad: I know it is not for lack of disk space -- fedora is installed on a 320 gig hard drive, and the os is almost the only thing on it.

This morning I rebooted to 32-bit MS-Windows XP and again downloading the file with Firebox browser. But this time 71% of the file has finished downloading in just one hour.

If linux (Fedora) is supposed to be so wounderful and better than MS-Windows, why does its file downloads suck cannel water:eek: And why could it not save that 3 gig file?