WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Speak English. nid? Use sentences. Violation of the Rules.
2) Give you code? Why should we do something you're not willing to do? What's in it for us? Violation of the Rules.
3) ASAP? What makes you so blamed important? All these other member's posts are less important than your program? Why?
4) email? Why should you get special treatment? Violation of the Rules.
5) Special treatment because you're a freshman? No wonder upper classmen dislike freshmen -- they're primadonnas.
6) How can you possibly defend something you didn't write?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hijack thread? He never mentioned hijack thread. Hijacking has nothing to do with this thread except it deals with new members not bothering to follow rules.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Enter date #1 and #2
Break both dates into day,month,year values.
Start with that and get it working. Then start the meat of the project.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What is the value of std::string::npos when the loop starts?

Looks like a do-while would work better here.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Add 3 textboxes (L, W, TOTAL) and a button to the form. In the button click event
- get the values in two boxes
- do your calculation
- put the total in the third box.

You seem to be relying on videos too much. Non-video tutorials will help you find specifics much faster. They also give you code you can test. I've never gotten code from a video.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't see an error message posted nor a line number pointed to. You might want to give us ALL the details, not just some of them.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i can get this to round up can anyone help? i have been using the ceil function but its not working right i get an error saying it cant be used as a function.
i put ceil b4 the ( in this formula below and i put ceil b4 the ( in the 2nd formula.

Are you unable to post the exact error? What does "not working right" mean? Why can't ceil be used?

You should know by now it's a waste of time to post questions without details because we just ask questions about stuff you didn't tell us. Then we have to wait for you. Hours and many posts later, you get an answer. Cut that time by figuring out what might help us understand and just explain the entire problem in one post. Errors and all.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

if (teamScore ==1 && teamScore != -999) If team = 1 it can't be -999. Simplify both if statements

cout << "Team 1" << score1 = sum + numPoints;
cout << "Team 2" << score2 = sum + numPoints;

Did they both score the points? Once the output is done, what's the value of sum ? Is sum important?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You know you are old when you read all these "you know you are old when" posts and think, "What are these young whippersnappers talking about?"

Or when something is 'remembered' as old and you think "that's old? I thought that was just a couple years ago!" -- and it was from the 80's

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

BTW, the iostream.h vs iostream is a stylistic thing which was inherited from C. The C style was to use iostream.h, in C++ it isn't necessary.

It's not a stylistic thing. The .H forms are deprecated and do things differently than the non .H form. The standards have moved forward since the 'inherited' form was designed.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

for(j=1;j=n;j++) You are not comparing j with n, you are setting j to n, therefore an infinite loop.

You need to think deeper about what you are trying to accomplish. Use pencil and paper to figure out what kind of loops you need, and how many.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What WaltP says is true, programming windowed applications, (I like to call it programming using Win32 API) is hard in C++.

[opinion -- read with a grain of salt]
Win32 API is different than what he's using though. He's using full blown windowing -- what came out of MFC I believe. APIs are lower level.
[/opinion -- corrections accepted]

If all you want are those calculations, then I really suggest you give Visual Basic a try.
They say it's really simple (haven't used it myself though)
But for the kind of program you're trying to make, visual basic is sufficient.
EDIT: Visual basic also has a visual interface (in Visual studio) where you can drag and drop stuff

I agree. It is much simpler than C/C++. Once you have the forms designed you can drop in the code you need at each object. in C++ you have to really understand the low level interface details. VB still isn't trivial, but it might make the programming much easier. I still use it today.

I haven't used this myself, but here's Visual Basic Express, a free download.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In your construction business, if you hire me and all I can do is drive a nail, would you have me pouring foundations, cutting moulding, using a rebar gun, and installing windows on my own the first week?

This is what you are trying to do. You don't have the background to create a simple program let alone one this complicated using such advanced techniques.

I understand your desire, but start with basic programming, then work up to using windowing. Basic programming is hard enough without trying to learn everything all at once. And you will hate what you write by learning everything in one shot.

But if you want to continue on this path, devour tutorials more than videos.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Left open hoping piracy would not be suggested. It was.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can't see your code. Can't tell what might be wrong.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

To be honest, I think Excel would be better than trying to learn C/C++ to do this. It's made for on-the-fly computations. It also makes it very simple to compare possibilities.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can anyone explain whats wrong with this program

void main(void) - see this clrscr (); - very old non-standard function that hasn't existed since 1986 getch (); - non-standard function that is very non-portable, works in very few compilers
and no formatting making the program hard to follow.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If I pass match[100] as an argument , doesn't that make it just the value at match[100]. I thought I the proper way to pass an array as a function argument was a match[]. I assumed this was a pointer to the first element and it could be modified accordingly. Was I wrong?

Yes, you were wrong.

(sub,match,100);

should work. match is the 'pointer'. match[] is defining it as an array, use in the function definition, not part of the executable code.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i did bother to look at the original code. the first thing i noticed was:

/*Header file declarations. You may not include any additional header files*/

/* Global variable Declarations. You may not include any additional global variables */

/* You may not modify the table[] global variable */ 

/* You may not modify the PrintMsg function */

/* You may not modify the calcError function */

I don't know what to do here, because there's not much code left that we're allowed to modify.

You are kidding right? Looking beyond the 'defined' code and I also see

void printPlainText() { 
	/* declare variables here */
	/* Place functional code here */
}/* function printPlainText */

void Count() {
	/* declare variables here */
	/* Place functional code here */
}/* function Count */

int main(int argc, char *argv[]) {
	/* declare variables here */
	/* perform initialization here */
	/* Place functional code here */
}/* function main */

which is most of the program. Use the data values defined to write the rest of the program :icon_rolleyes:

jephthah commented: c'mon man, open your eyes: the OP is b.s.'ing us, he's trying to get us to do his homework for him. -1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
while (!inFile.eof())
	{
		for (index = 0; index < 501; index++)
		{
			inFile >> num[i];  
		i++;
		}
	}

Why are you putting a for loop inside a while loop? Get rid of the for loop.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Then you aren't reading a \n.

After reading the character, immediately display it's binary value cout << (int) nextchar; If you don't see the value of '\n', you aren't reading it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes it is. Engage brain and think. How can you look for a ';' instead of '\n'? As I asked before

Are you looking for a '\n' right now? Where?

If you can find that spot, think of the change necessary.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Same comment.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't see any writing to any file. You might want to open/write/close a file and you might get banana into the file.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you need to get the command, why do you skipOverRestOfCommand()? Why are you throwing the command away? Save it and returnTheCommand() instead.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you guys bothered to look at the code you might have noticed in the original post:

/* Global variable Declarations. You may not include any additional global variables */
int cntLetters[NUM_LETTERS], totalLetters; 
char cipherText[BUFSIZE];

I wonder what cntLetters[NUM_LETTERS] is for?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't think I understand the problem.

Are you looking for a '\n' right now? Where?
Do you want to use a ';' instead?
Isn't this fairly obvious?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Way way too complicated...

Input the two numbers like you did.
To print the even numbers, just use a for loop that goes from Number1 to Number2 incrementing i. If I%2....

Same with the odd numbers.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sorry, wrong answer.

Read the numbers into num like you did, but you need to convert them into numbers (atoi() would do it) and load them into that array.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

As long as you are reading from cin in the code, using
progname <filename.txt
will read the numbers from filename.txt

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How does that work im not familiar with it.

Like this

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So you read the entire file into the single string num

while (!inFile.eof())
{
	getline (inFile,num);
cout << num;
}

Then you call bubblesort() passing in the one string value num and sort this one value maxSize times.

bubblesort(num,maxSize);
	outFile.close();
	inFile.close();

What happens when you try to access num[1] , num[5] , etc?

Do you need to think this through a little more?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You have to find the directory the .EXE is in and set the command window into that location. Then create the file there too.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

VB6 is probably no longer available, but VB-Express 2008 can be downloaded from here

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How can I do this? (I know in gcc its a.out < input.txt);

It's the same on the Windows command line.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Use strlen() since you are entering characters.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And I'm the second one to agree with FBody. Do you still think he's wrong?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So close! You just overdid it. Your while statement (why did you change it?) now reads 2 characters, not 1. And why do you have to check for EOF anyway?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you enter XI the input buffer contains X, I, ENTER.
The only way to exit your main while loop is to not see a Roman Numeral. That would be ENTER. Therefore the input buffer is empty and you exit the loop.

Now you enter the next while with:
* rdigit = '\n'
* input buffer empty

You need a little more code to make it work -- very little.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I just did. Read the post.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You remember what happened when the lady on the radio yelled
"Don't open that closet, McGee!"

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

you can do this in scanf itself,

scanf("%10s",Name);

No, don't. Getting used to using scanf() for strings is dangerous because it is too easy to use it wrong. And there is fgets() , which is safer all 'round.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Read it as characters and convert the character '0' to the number 0.

fgets(z, sizeof(z),stdin);
    tk = strtok(z," ");
	while( tk != NULL){
			  c[index] = atoi(tk);
              index++;
              tk = strtok (NULL, " ");
			  }

Keep the fgets() statement. Throw out the rest.
Loop through the buffer read and follow what I said above.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

There certainly isn't enough information in your description to even make an educated guess.
Maybe you need to use a debugger to follow the program through the printing section.

Also, if you'd consider using arrays, you can remove all those if statements and make your code smaller and a little more understandable.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

scanf is often the source of input problems. as you can see, you have the most trivial example and it's already being problematic. since there are better alternatives readily available, you'll do well to learn to stop using it as soon as possible.

While you are bashing scanf() and gets() , might as well quote you with one minor change:

anyone who ever suggests that you use scanf("%s",) is also an idiot. this especially includes programming instructors. here is why.

:icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Almost. Doesn't that print the message multiple times?

Use while(getchar() != '\n'); Be sure the ; is at the end and you will read all the leftover characters in the input buffer.
But you have to place it in the code after you are done with your input and you know there are more characters unread. So you need to think a little more on the placement.

Hint: Somewhere in get_roman(void) is where it needs to go.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It's because a for is structured as for (initialize; condition; increment) So if you have for ( int i = 0; int j = 5; ; i++ ) which is the initialize, condition, and increment.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i want to figure out a way other than a switch statement that will show the user how many gallons of paint are needed when the user says how many square feet they have.

If you don't want a switch statement, use a series of if statements.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

... if you remember using data cards and/or paper tape.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What value does 5% represent?

Hint: it's between 0 and 1.0