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

Did you read and write the rest of the file? Or did you think the records past the last one you read would magically move over to the new file? :icon_wink:

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

Where are you calculating the grades?

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

It however, gives me:

1>Compiling...
1>grading.cpp
1>c:\users\documents\visual studio 2008\projects\grading\grading\grading.cpp(34) : error C2059: syntax error : ']'

This was in reference to(which is in the main function) :

check_correct_answers (answerKey[] , studentAnswers[] , grade, score);

Change it to check_correct_answers (answerKey , studentAnswers, grade, score); When passing an array, just the name is necessary.

You must call the functions when you have data. You can't call the functions willy-nilly just to get them in the code.

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

Yes, they are there to provide you with the answer. Just because you buy a bread machine does not mean you always have bread ready. You have to actually use the thing first. Where did you use the functions...

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

Try commenting your code:

getline(inFile, answerKey);           // Get the answer key

   cout<<"The correct answers "<<answerKey << endl<<endl;
   while(getline(inFile, studentID))     // Read student ID
   {
     cout << studentID <<" ";            // display the current student

     getline(inFile, studentAnswers);    // read the student's answers
     cout << studentAnswers << endl;     // Output the answers
   }
	return 0;
}

What seems to be missing?

And you still need to work on your formatting.

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

i've enumerated the months with the number of days in each month

how do i rig it so that what ever the user types for their two months counts the number of days in the months between? could i use a for loop like:

for (int i=first month; i<last month; i++)

my brain is fried

-___-

Sort of. If you don't want the first month added use for (int i > first month; i < last month; i++) But, what if your dates are 15-Sep-2006 to 22-May-2007?

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

>gets(name);
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1049157810&id=1043284351

Yes, gets() is a very dangerous function, as is scanf("%s",...) in exactly the same way.

>clrscr();
Non portable

As is getch() . Best to remove conio.h completely and use no functions from it because most compilers won't be able to compile your programs.

>while (!fil.eof())
Doesn't work as you expect it.

For further information, see this, .eof() is exactly like feof()

Modification of a file would be better achieved by creating a temporary buffer with all the changes then overwrite the original file.

Another alternative is to simply write each record to a new file. When done, the program can delete the original file and rename the new file. This will also save all the file pointer stuff you're doing now, making the code much simpler and safer.

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

DaysFirst = How many days left in the first month
DaysLast = essentially the day of the last month - 1
DaysMonth = number of days in each month between the two months

Add them all together.

Example:
4-May-2007 to 23-Sep-2007

DaysFirst = 27 (31 days in May - 4)
DaysLast = 22 (day of the month - 1)
DaysMonth = 92 (June/30 July/31 August/31)

Total= 141 days

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

If you're having more problems, ask a question.
If this project is done, start a new one.

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

How can i get the info from the infile(one data stored on top of the other) to be stored into the arrays and i have? Thx for your input.

You're close.

Defining char letter[30]; gives you letter[0] thru letter[29], therefore this code

inFile>>letter[30];
	inFile>>item[30];
	inFile>>cost[30];

reads the first 3 values into the array entries after the array definitions.

You need to put the inputs into a loop, using the loop index from 0 to 29 as the index into the variables.

Also, consider using whitespace for readability. For example

//Display receipt
	cout << endl;
	cout << "Zandiago’s  Z-BURGER SHACK" << endl;
	cout << "Amount" << mealprice << endl;
	cout << "6 % Sales Tax" << tax << endl;
	cout << "============================================" << endl;
	cout << "Total" << total << endl;
	cout << "Amount tendered" << amount_tendered << endl;
	cout << "Change" << (amount_tendered-total) << endl;
	cout << "Thank you for visiting"'\n';
	cout << "Zandiago's Z-Burger Shack" << endl;
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Personally, I'd read the test answers into a char* rather than a C++ string . A char* must be defined to accommodate the total number of answers necessary, but a string will read only the answers on the line. If a student doesn't answer the last 5 questions, the string could be short and cause problems. A char* will still have data, however it will have to be cleared after each use.

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

When a customer orders, the cashier presses a key for each item ordered (WITHOUT PRESSING
<ENTER>). If more than one of the same item is ordered, the key is pressed an appropriate
number of times. As each key is pressed, the name of the item and its price are displayed on the
next available line on the monitor....

Ouch!!! Considering Standard CPP cannot do this, your instuctor is teaching techniques that cannot be used normally in the industry. I don't like this at all. :icon_evil:

If you look at my infile (as show before), how do i get the data from each individual line to be stored in the array?

Read the line and break it up into it's 3 parts. To learn the most, test the line character by character and process each section accordingly.

Have you considered using a struct or class for each item on the menu?

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

That's kool, but how does that help the next person that comes by and expects answers from a search? Now only those that read this thread understand heuristics, but the other 223,045 members (and uncountable lurkers) still have no clue (not that they'll read it from the search page anyway, but there's a chance). :icon_wink:

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

> How about saying that on the search page that you use a heuristic for performance reasons

I think that it can pretty much be assumed whenever querying a huge dataset that some level of heuristics are involved. There would be no positive benefit to having such a disclaimer.

No it can't. Most users that search have absolutely no idea what backend they are searching, nor the extent of the information being searched. A webmaster may understand, but non-web-gurus don't. I do not consider myself a neophyte, nor is Salem, and it seems neither of us made this obvious assumption.

I'm with Salem here.

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

You need to describe the error. No one is going to spend an hour trying to find the error, then pour over your code to fix it. You need to describe the error and the circumstances with which it happens.

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

if (islower(x)) can be written if (x >= 'a' and x <= 'z')

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

Can someone tell me what i'm doing wrong:

Depends on what you're trying to do, what it actually does, and what it's supposed to do.

Can someone tell me what i'm doing wrong:

Formatting for one.
Explaining nothing for two.
Not posting errors for three.
Read this for further help.

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

Your problem is using the wrong way to test for the end of a file:

while ( !myfile.eof() )

See this ( feof() is the same as using .eof() )

Salem commented: A nice link of traps to avoid +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It's because cin >> leaves junk in the input buffer when the command is finished. Use getline() instead, but you will have to remove the trailing '\n' that's in the string you read, which is an easier problem to deal with, IMAO.

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

The assignment is :

This is so crazy, here is what I've got so far:

So what is it you need help with? You need to ask a question so we know what you need help with. Just posting unfinished code and the assignment says "finish this for me, please".

So what's the problem?

One thing I did notice, though, 1/3 is 0, not .33333. But 1.0/3 will work.

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

I just did a quick check and found the following :icon_twisted:
(this is mostly just in fun, don't get your knickers in a knot)

Some of my old problems are back                    Sep 29th 2007 3:38 pm
Cursor is disappearing                              Sep 6th 2007 6:27 pm
Scroll arrows won't repeat.                         Sep 6th 2007 6:26 pm
Enough is enough!                                   Aug 31st 2007 11:00 pm
Bumbling highlights square.                         Aug 31st 2007 8:27 pm
Get rid of the editing time limit!!!!!              Aug 25th 2007 8:51 pm

So over the past month you've complained a lot about problems (real and imagined)

You seem to have taken the summer off, but in May posted:

Stuff has stopped working.                          May 25th 2007 8:43 pm
Can't read what I am posting                        May 25th 2007 8:40 pm
Pages are jumping crazily around                    May 11th 2007 4:18 am
Dropdowns close when cursor over link underneath    May 8th 2007 4:39 pm

Just find it interesting.... :icon_wink:

~s.o.s~ commented: Heh, nice observation. ;-) +21
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

strstr() does not work on string class, only char* s. Look at the string class methods to find your substitute function/method.

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

I know it's been suggested before, but a beta.daniweb.com would, in my opinion, be a vast improvement. You'd get a good idea of what kind of feedback you'll receive when you release it to the public, you could select users to test out your new changes, and once you've as many bugs as you can ironed out, release it. For users, it would mean learning the updated UI less often.

This I agree with -- for changes that actually affect usability. Moving buttons, changing fonts, things that make the site different in operation or strong visual changes.

That's definitely by all means standard for software. However, when was the last time you saw google.com or digg.com or cnet.com or any other large website for that matter publically release such a document? The answer: they wouldn't.

I rarely see them make small changes on a daily basis. They may innocuously tweak something, but when large changes get rolled out all in one shot, and I'll bet it's only after a strong beta-test from select users. They are (probably) never implemented so that the entire user base sees them for the first time.

So that I won't be accused of failling to mention it, a UI change made today was to surround the list of sticky threads with a thin box to separate them from the regular threads a bit more.

This is something that can be done 'on the fly' because …

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

Yes it is... You have to know the value of PI and then divde it by 17 then add 4 then goto 'AREA 51' and get the secret link to click to retrieve it!

I know the value of PI -- 6.98 for a fruit PI, 7.98 for cream PI...

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

At the end of your code, you have

cout<<"\nPlease enter +,-,*, or / and then two numbers,\nsepperated by spaces, that you wish to\nadd,subtract,multiply,or divide.\n\nType e and press enter to exit.";
        cin>>choice;
        if (choice != 'e')
        {
            calc(choice);
        }
}

This will only run the calculator once. Change the if to a while (with a couple other obvious changes) and you should be good.

Also, see this about your void main()

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

Yeah. Popups bad. Me no like. Gross!

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

It's a secret message you're to authorized to read... :icon_twisted:

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

Or add a progress bar or textbox to the modal form to display the progress. As an added safety, disable any 'dangerous' buttons while the command is being executed.

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

My advice is to tell us what the errors are. the more you explain the problem, the better (and faster) we can help you solve it.

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

about the fflush, I know its wrong but I guess since I'm a beginner it's easier to just tell me to use that while learning the basics since portability will be an issue later...

And after you've learned to use it, and after time forget that it's wrong, what are you going to tell your boss when the program doesn't work with their compiler when you get a job? Tell him "it always worked before!"?

... but for now everyone is using the same compiler so all is well and you can add that to the article which lead me to this site, "What Are They Teaching C Programmers These Days?"

As my mom always said, "if all your friends jumped off the Empire State Building, would you do it too?"

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

Below is my code: Why does it not print anything out? As you can see in my previous posts, i was using a wile loop, howver, my instructor said i can't use it.

Comments point out problems:

#include<iostream>
#include <string>
#include<fstream>


using namespace std;



int main()
{
	
	ifstream inFile;
	ofstream outFile;

	inFile.open ("random.dat");
	outFile.open ("randout");

	int numbers[91]={0};
    int counter=0;
    int num=0;
    
    inFile>>num;
    
    {
    bool found = false;
    for(int i=0;i<=counter;i++)  // counter is 0, so i is always <= counter
    {
            if(numbers[i]==num)
            {
               found=true;
             }
    }

    //// after you get here
    //// 1) you never saver any index so you don't know which
    ////      numbers repeat
    //// 2) counter still has no value
    if(!found)
    {
		cout<<"These are the non-repeating #"<<endl;
        numbers[counter++]=num;
    } 
	inFile>>num;
        //// You just read a number, and exit the program

     }    
    return 0;

}

You need to break you program into steps.
1) Read all the data
2) Next, look for duplicates and remember them by setting a flag in another array. Use 2 nested loops.
3) Loop through the flag array for any non-set values, those are the non-repeating values

So I see 4 loops necessary

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

longs are numbers
"" is a string constant
You can't mix the two.

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

Why am I receiving the following errors:
'seenBefore' : function does not take 1 arguments

bool seenBefore(int, [B]int *[/B]);

syntax error : missing ';' before '}'

Depends on where the error is. This is why we ask you to post the exact error message, in full!

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

He didn't rep me at all!! Let's ban him!

Aia commented: Here, don't complain +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why a null terminator after each character input? I guess it was a typo.

char string[100];
for(int i=0;i<100-1;i++)
{
    string[i] = getch();
}
string[i+1] = '\0';

And yours has them too. Wrong location for the c-string terminator

char string[100];
for(int i=0;i<99;i++)
{
    string[i] = getch();
}
string[i] = '\0';
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

getch(); does not work in graphics.h. I mean I need to input text.

And what makes you think it doesn't? What happened when you tried it?

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

Only Ancient Dragon has the correct answer. You cannot ++ or -- the same variable in the same statement. The C Standard says doing so is undefined and not guaranteed to give the answer you expect. See this and this.

Salem commented: Good FAQ links +9
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The idea here is to make each character in the string exist in every position, for example:

string is "JOY"

so taking J:-
1st pass: "JOY"
2nd pass: "OJY"
3rd pass: "OYJ"

taking O:-
1st pass: "OJY"
2nd pass: "JOY"
3rd pass: "JYO"

taking Y:-
1st pass: "YOJ"
2nd pass: "JYO"
3rd pass: "JOY"

then remove the repeated results, and you'll get all the combinations for that string

But you missed YJO, so your algorithm is flawed. :icon_wink:

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

graphics.h does not exist for Borland 5.5, so it won't work.

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

#1: Please learn to format your code so we can read it.
#2: You added a line to the input file. Where did you add the read for that line?

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

I am just seeking help as I need it urgently.
I have read the other posts.

If you want help, you have to ask a question that can be answered. Details are necessary.

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

can u type any random letters and save it as an .exe file and then run it and have it work?

what is an .exe file?

No. Random letters will rarely if ever generate executable code.

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

I am a beginner in computers, i would like to be assisted in writing a simple program that inputs a fraction in the form of a/b and c/d and culculates the sum and returns the answer in the simlest form as in p/q.

...

Lookin forward to your prompt and positive response.
thanks

Sure. But you didn't mention what help you need? Is there something wrong with your code?

Also, please read this and this. They will help you get the best help possible.

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

First thing I'd do is calculate the random value first. This way you have the option of asking "Do you want to try another number?"

Next thing, rather than asking for each individual number (since you are only using 0-9) have the user enter a 5 digit value.

I'll let you work out the syntax for your program, but an array is just a variable that can contain multiple values. For example: int ary[5] defines the variable ary to contain 5 values, ary[0] thru ary[4]. So in your code,
ary[0] would be a
ary[1] would be b
ary[2] would be c
ary[3] would be d
ary[4] would be e

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

Pass the array into the function and load it, rather than trying to pass back a local array from the function.

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

As for the smilies situation, the reason it is in the list twice is that someone might want to use it for either poking their tongue out or winking, which are different things. The same graphical representation fulfills both though, if you see what I mean.

So the meaning of a post gets lost in the ambiguity between wink or tongue. Not a good decision IMAO. ;)

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

To pause use system("PAUSE");
and #include <stdlib.h>

No, do not use system("PAUSE") . Here's why

Aia commented: Always helping people. +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Reeciepoo, after 15 threads, with useless titles like
Help
Databases
Need help
HTMLWrapper
How do you
Noobie
How the hell
Annoying Network Issue
Network Configuration
Some help please
Recommendations
Changing Font
C++ Help
it's probably time to read the Rules, especially the Keep It Organized section.

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

Can you compile programs that don't use the graphics package? Or do they also claim "could not load tlink.exe". I doubt it's because of BGI. It sounds like your compiler isn't set up properly.

I'm constantly amazed how people use an ancient compiler with an obsolete graphics library and expect it to work seamlessly with the latest operating system...

And -- with all due respect to one of our most knowledgeable members -- I'm constantly amazed that everyone thinks that just because a compiler is old it can't work! I can still build BGI programs with no problem with Turbo C++ 1.0 on up-to-date XP. Just did it without errors, warnings, nor glitches.

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

What's the value of sales when the program starts?

And use Code Tags!