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

elf_handle is probably defined wrong.

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

Also, in your editor's options set the TAB key to add 4 SPACEs instead. All those TABs make the code harder to read.

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

Problem I am experiencing: When I compile my code, I get these two error codes:
1) In file included from C:\Users\PaulWilliams\Desktop\CSci Work\C++ Programming\TestScores.cpp
2) unterminated #ifndef
I am not understanding what I did wrong,

Unterminated:
Without end; having no termination. from wordnik.com
does not end, conclude, or cease. from dictionary.com

So where is the end of your #ifndef?

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

Three post -- each one a description of what you are trying to do.
No acknowledgment that someone tried to help.
No answers to the questions asked.
Obviously not interested in help.

On to the next person. Hope he actually wants help.

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

I don't see what's so hard to understand.
There are 5 text boxes, each with some text.
There is a command button labeled ascending.
Click this button and the
-- first checkbox contains the smallest ordinal value of the 5.
-- second checkbox contains the next smallest ordinal value.
-- etc.

ruudycruise, based on your second post, my suggestion didn't help?

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

Since you are using a C++ string, use the string functions .find(), .substr(), .erase()

With a simple GOOGLE search I found this

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

Ahhh, I see...

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

Everything posted is fine.

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

Because integer division truncates. 200 * (1/2) = 0 because 1/2 = 0 using integers.
Cast your values to floats during the equation: (float)200 * ((float)1/(float)2) = 100

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

Yes, it's completely possible. Set up an index array idx . Then month[idx[2]] and dblval[idx[2]] will be a matched pair.

During the sort, check arrayEntry[idx[i]] with arrayEntry[idx[i+1]] and if they need to be switched, switch only idx[i] and idx[i+1] . The actual arrays stay in their original order, only the index array gets sorted.

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

Thanks, that push was actually VERY helpful.

Good.

I'm almost done, but there's an algorith to compare the colors and i'm not sure how should i do it, nothing good comes in my mind and i actually wasted pretty much time with it

Since I don't know the algorithm, nothing comes to my mind either.

btw, how do i check the fopen function for errors?

Try This
And while you're at it, This Too

i have also put in the \n in the scanf to take it out

:icon_question:

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

i did this game long ago... when i was in grade 8 but i did it in qbasic..you want me to search the source code....??
and for the c++...i will try to do it...

No. Start like I said before. A piece at a time.

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

1) How can you have 2.4 dimes? Or 3.7 quarters? The values of the denominations only need to be integers.

2) Have you spent 6 hours sitting in front of the computer just whacking at the code hoping you get the right answer? If so, you are missing the most important part of programming. Writing out how to do what you need to do, changing it until you understand the process completely. Only then should you sit in front of the computer.

Writing a program is like taking a trip. The computer work is the driving part of the trip. But if you don't plan the route to where you are going, how can you ultimately reach the destination?

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

well the program is supposed to take in a set of numbers convert them with the function salary and then count the number of entries that fall in that range
the numbers counted in the ranges should change based on what is entered so what is making rangeA always 11 and rangeI 40
ive been trying to find out what is casing it
i got a feeling its gonna seem so obvious when someone points it out to me

OK, here's why we can't answer you:
When I add the number of letters in my full name I get 12. But that's wrong. What am I doing wrong?

Have I given you enough information to fix my problem? What else do you need to know to tell me what's wrong?

In other words -- think about what you you need answered and give all the information you can to show us why your answers are wrong. The key is think!

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

Please see this to format your code so we can read it (it's very hard to follow as it is) and also this about main().

What is the value of sizeof names[i][j] ? Are you sure this is what you want?


It really helps to print the value of important variables as the program runs to make sure they are the values you expect.
1) If they aren't what you expect, figure out why.
2) If you don't know what to expect, sign up for shop :icon_mrgreen:

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

yea, i ignored your help, because you did not help me with my code at all, and I did not know what I needed to take out. All I read was advice, NOT HELP. SO I did believe you, you just did not help me. This is a program for my homework assignment and I have been working on it for nearly 8 hours. Could you please just show me in my code what I need to take out. PLEASE.

Now I understand....

I gave you the answer. I explained exactly what you need to do. All you want is for us to do it for you. Sorry, I graduated in the 70's. I don't do homework today.

Bye...

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

yup, I complied it in Dev C++. Its weird, if I take out the second loop it will run forever, but the second loop will stop the first one.

Yup... That's because you completely ignore the last help I gave you. I even told you the loop would never end. But did you believe me? Noooooooooooooooooo :icon_wink:

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

Probably because you ELSE clause does a getchar() and throws away whatever it read. I doubt you need that particular ELSE.

And your IF structure is inside out. You should be checking your characters first. Then check your flag only when you need to.

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

THanks Waltp i was just writing peace of the code not all of it. But Arbus answer was really helpful and thats the exact thing i wanted

Maybe so, but what I wrote was something you needed. There's a difference.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
int main()
{
	int i, j, k=0, test, n, m;
	char **garden;
	char c, colors[100];
	FILE *be;
	be=fopen("G.IN", "r");    // How do you know the file was opened correctly? 
                                  // You didn't check for any errors.

	fscanf(be, "%i", &test);  // You read the first integer but the \n is
                                  // still left in the file. I suggest you read
                                  // a full line and convert the value to integer

	for(i=0; i<test; ++i){
		if(fgetc(be)>64 && fgetc(be)<91) 
                                  // This statement reads the next two characters and
                                  // checks the first to be > 64 and the second < 91
                                  // You probably want this to be after you read the 
                                  // line then check the first character in 'colors'

		fscanf(be, "%s %i %i", colors, &n, &m); 
                                  // Again, read the entire line then convert.
	}

	//system("pause");
	return 0;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It isn't possible with Standard C. You have to learn special function added by the compiler authors for your specific compiler and operating system.

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

because its a matrix and i have to use it in a multiplication...

Yeah, so?

If you have a matrix defined int matrix[100][100] and you only load the values from matrix[0][0] thru matrix[19][29] , why would the rest of the matrix be used for multiplication? Just use the part that's loaded, thru matrix[20][30] .

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

Really? That makes no sense.

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

Sorry, my fault. I'm not used to seeing the IF in that style. I've always used if ((val >= 300) && (val < 400)) to check for 300-399.

However i keep getting incorrect results
no matter what i enter i keep getting 11 for the range 200-299 and 40 for the range over 1000

With the information you provided, 11 is probably the correct value for RangeA and 40 is correct for RangeI. You'd have to show us why these values are wrong, not just tell us they are.

And what about the range from 0 to 199? Those values will be added to RangeI the way your IF is set up.

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

Do you know the difference between 10 and 10.00? What type of values they are? And what type of variables are needed to hold them?

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

However, in my switch statement it does not generate random numbers like it did earlier. You'll see what I mean.

There are only 5 switch statements. And how would we see what you mean? You didn't bother to describe it.

Other than that I need help with the scoring part of the assignment. Can anyone please help me? I feel like I am close to being finished with my programming I class final...Yahtzee.

With what? Without a description of what you are having problems with, we can't very well help, can we?

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

Why not make the array large enough to hold the largest message you expect?

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

Copy the text boxes into an array. Sort. Write the array back into the Text boxes.

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

It's still stupid of you. You didn't even bother to read what I posted.

Again, what are you testing when ro = 0?

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

Don't make new threads for the same problem. Continue with the old thread.

And you know you could just post the relevant code, not the entire thing.

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

Now your code doesn't make sense. With your two loops you just complicated the issue.

Get rid of the second loop which is redundant.
Read all the values before the loop.
Read all the values at the end of the loop.

And by adding .eof() you now have the problem that the loop doesn't exit if a different error occurs.

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

You need to use a flag to keep track of whether or not a \n has already been output.

Start with the flag set to TRUE.
When you output a character, set the flag to FALSE.
When you want to output \n, test the flag.
If the flag is FALSE, output \n and set it to TRUE; if TRUE do nothing.

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

if ro=0 and co=5, if (grid[ro-1][co] == '.' && ro-1 < ROW) will first test grid(-1,5). Is that a valid test?

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

I need some help with the toupper code.

int main()
{
char pick;
printf("A. Local needs\n");
printf("B. Local Service\n");
scanf("%d",& pick);
switch (pick)
{
case 'a':
printf("Hello World");
case 'b':
printf("Hello Nation");
}
getch()
return 0;
}

How would i implement the toupper code so i could change pick to upper case if the user entered a common letter. And do i have to # include anything at the top to use toupper?

Q1) Do you know what %d does in your scanf() call?
Q2) What does the documentation say about using toupper() ?
Q3) Has anyone taught you how to format your code? If not, see this

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

Good try -- it's the right idea. Go back to your first code and:

Read the first line as you just did outside the loop.
Inside the loop process all the data read.
Read the next line as the last thing in the loop.

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

Take it a step at a time. Create the class, output the board. When you can do that move on to the next step whatever you think that is.

You add information to the class as you discover you need it.

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

Read three lines in a row. The last read is the one you want.

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

numberOfColumns is not a "constant value" so you can't declare your array the way you did.

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

Because !infile is TRUE until you hit the End Of File. When you read the last line, you still haven't hit EOF so you fo through the loop once more. The first input hits EOF and continues through the loop since you are beyond the check already. The last line read is still in the variables.

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

I'm sorry. I didn't realize the only help that will be accepted is to have us write the code for you. I was hoping you'd be interested in learning enough to do some of your own work, not rely on others to do it for you. Again, sorry.

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

I know what I meant to imply, and it has nothing to do with memory attributes. I see I should have quoted the entire statement. So corrected.

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

Technically speaking, the only difference between code and data are memory attributes. So an array could carry values that equate to a function calls but you could not call them unless you changed the memory attributes to read/execute and pointed the instruction pointer at them..

:icon_rolleyes:

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

Would you write a EOF loop as:

while(inFile){
}

I wouldn't. I'd do the search and learn from what I find.

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

You need to rethink these comparisons. Read them out loud and see if they sound correct:

if (200 <= salary && salary <= 299)  
           else if (300 <= salary && salary <= 399)  
            else if (400 <= salary && salary <= 499)  
            else if (500 <= salary && salary <= 599)  
            else if (600 <= salary && salary <= 699)  
            else if (700 <= salary && salary <= 799)  
            else if (800 <= salary && salary <= 899)  
            else if (900 <= salary && salary <= 999)  
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What's the value of totEmpl after the headings are printed? Print it out.

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

There are plenty of examples on this site. Use SEARCH.

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

No. An array is a list of values. Values can't call functions. Only code can call functions.

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

I don't see an "an EOF controlled while loop" anywhere in the code at all. We can't help fix what's not there. Set up the WHILE loop, read from inFile, and when EOF is reached, exit the loop.

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

Sounds like a question for the teacher. I feel certain he has the answers that we seem to be missing.