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

It really helped when you commented to each line to show what starts first and where it ended.

It really helps more when you comment your code... FYI :icon_wink:

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

Thanks for the advice, very much appreciated. I've altered the code as suggested and is a lot 'cleaner' looking.

Not bad, although it's still not formatted properly.
By the way, what does cin.clear(); do? You might want to look it up.
Another thing to look at is system("PAUSE"); See this

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

Weird school :)

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

Someone forgot the CODE tags that were mentioned in the Rules you read when you registered. Not only that, you typed right over exactly how to use them when you entered your message. It helps us help you if you try harder.

You also neglected to format your code. This also helps. Aren't instructors teaching how to properly write code these days?

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

int *buf declares buf to be a pointer to integer.

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

Did you miss the request to read the Rules when you registered? Did you also miss the post Read Me: Read This Before Posting? What could we have done to have you understand the importance of reading this information?

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

Only if you'll bother to read The Rules as requested when you registered, and the post entitled Read Me: Read This Before Posting. Also, please tell us what we could have done to express the importance of reading the rules first?

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

I also used the

while(!=feof(in))

you had suggested, the reason I was reading it twice was to find the length but using your suggestion I just added a counter to get over that and just read it once.

I would never suggest while(!=feof(in)) !!! See this and you'll see why.

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

Please learn to format your code better so we can read it. Pay attention to the Indentation section.

Look at the parameter types in the function call you're having trouble with. What are the variable types the function expects, and what are the variable types you are passing?

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

Using proper formatting helps solve problems like this...

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

A few comments on the code:
1) Please use better and consitant formatting so the program can be understood. It help both you and us.
2) getch() and conio.h -- They are not standard and you don't need them. cin.get() is standard and does what you need.
3) void main() -- main is an int, never a void.
4) if(fin.peek()=='\n')fin.ignore(); -- what are you testing here? What if the next character is a SPACE? Probably better just to getline(fin) or fin.ignore(100,'\n')

I am trying to take the following code so that my bottom function first pulls out the first three scores of a text file and averages them, then pulls the last three scores out and averages them. I am using a known good text file that has 7 entries with first and last name folowed by the 6 scores followed by a return and the next entry.

Can't make head nor tail of your average function:

int calcAverage(float average[40][6], string names[40][2], int scores[40][6], int &counter)
{
    counter=0;
    for (int col=2; col<8; col++)     //// start a loop....  why 2 to 8?
    {
        return average[40][6];        //// first thing done in the loop is return an 
                                      //// illegal value (last value is average[39][5])
        cout<<average;                //// never reaches this line
    }
    int Ptotal[40][3];                //// Never got here, already returned.
    Ptotal =0;
    for(int col =2; col<5;col++){Ptotal += scores[col]
    }cout<<Ptotal;
}//end of outer for

Are you trying to calculate one of the two averages here? …

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

Yes, it's possible. Make an array of the class employee. As you read the file, load the class. You can then access employee[x].FirstName, etc.

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

I was just trying to figure out how powerful or useful pointers are because they just seem worthless to me...thanks for your help though.

Then you simply don't know enough of the language yet. The knowledge and understanding will come. You don't need to rush it yet.

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

Thanks for that but do you know how to write the information into an array? Or for that matter how to split this string into individual parts for the structure?

Yes. But it depends on lots of things -- format of the file, what the array looks like, what delimiters are in the string. Details help make decisions.

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

52 C:\Users\Desktop\coding.cpp initializer-string for array of chars is too long

This one is quite obvious. How many characters are you trying to stuff into what size array? Remember, c-strings must end with '\0'

C:\Users\Desktop\coding.cpp:83: error: `clrscr' undeclared (first use this function)
C:\Users\Desktop\coding.cpp:92: error: `sleep' undeclared (first use this function)

Where did you define these functions? They are not part of standard C++.

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

The SPACEs in the scanset seem to be the problem. Remove them and see if that works for you.

Also, check out this information on
main()
while (! feof(in))

And what is the purpose of reading the file first? Just read it once.
I would also suggest rather than using fscanf() you switch to fgets()/sscanf() combo. If an error occurs with fscanf() it's harder to recover.

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

Overall, I think you're right, but throwing that sentence to him wasn't very supportive. :)

Maybe not, but it's quite tiring day after day, week after week, to get "what's wrong" or "help me" posts with no information nor code. Especially when multiple times during their registration new members are requested to read the rules. And on top of that, right at the top of the forum is a post titled "Read Me: Read This Before Posting". If they can't be bothered, sometimes they have to take the heat, IMAO. We're volunteers, after all.

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

Yes, most of us can answer the question -- if there was one. There was not one :icon_question: in the entire post, so no question was asked.

On the other hand, if the question was actually implied and was "can someone write code from this problem description" the answer is again, yes.

On the off chance the real question was "can someone write code from this problem description for me" the answer this time is no. We are not a homework service.

My question to you, nbs_87, is why are you hijacking a tutorial thread and not posting in your own thread as the Rules and the post Read Me: Read This Before Posting suggest?

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

Dean, please explain what was wrong with the first response you received? Lerner's assessment was right on. I guess my question is in your first post did you follow all the suggestions in the post titled Read Me: Read This Before Posting? If you can honestly say yes, we're sorry. If you can't, post a question that we have a reasonable chance of answering.

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

tarekkkkk, please use full English so we can all understand you. Don't use web-speak because a lot of people here don't understand it.

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

Euhm,

What the heck is this?? Clearing your throat so you can type? :icon_rolleyes:

I think he outlined his problem well enough in the first post actually...?

Really? No code. No mention of child processes. Nothing to go on. Outlined, yes, you're right. Enough to help, no.

Post 2:
Code -- that's good.

Child 1 & 2 implies Parent code. Which of the three is the code posted? Only a vague description of the difficulty. All information in the post looks like it's the way the code should work for text files.

We need to know details of the problem, not just "it don't work, why?" And he would have known that if he bothered looking at Jishnu's link.

However, I'm not immediately seeing a possible cause for the error.

See? You don't know where to look nor what to look for.

I rest my case. :icon_razz:

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

Why would you type forum when there's more than one? :?:

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

Child 1 opens the file and read a character, it then passes the a character to Child 2. Child 2 now take the received character and writes it a file.

Child 1 stops reading when the read is EOF.
Child 2 stops writing when it receives a '\0'.

Thank You

And? Are you proud of the code and want us to marvel at it or do you have a problem?

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

this and this will help

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

You are kidding, right?

Kidding about what? I don't understand what you mean. Let's look at what Lerner said:

Your code is almost impossible to read due to poor formatting. Learning how to format with consistent and appropriate indentation will save you lots of time trying to debug and make it easier for others trying to help or trying to maintain your code.

You want help but don't want to make your code readable? Why not write it in Swahili then.

I don't see where you declare outfile at all, so trying to close it is definitely a no-no.

This is a definite error in your code. It can't run correctly without it.

I don't see any arrays as called for in the instructions.

You can't pass if you don't follow the instructions.

I don't see any functions as called for in the instructions.

You can't pass if you don't follow the instructions.

First thing I'd do is comment everything out of the code from this line down:

inFile >> intRate;

Then develop a loop to read the entire file, outputting at least one set of information to be sure you're reading it in correctly. Once you've got that you can proceed further.

A reasonable suggestion, so YOU can figure out what your code is doing.

So no, Lerner is not kidding. Are you saying that as an IT Major you don't need to learn any programming? This is news to me. Even so, we …

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

First thing is try a little harder to get the indentation consistent. Code is much easier to debug when it's consistently formatted.

And to help you with this, here's some help

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

Read the Rules as you've been asked, and the post titled Read Me: Read This Before Posting.

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

Is using '#' to deliniate lines required by the assignment or is it something you dreamed up on your own?

while( cin >> name >> street >> city >> state >> zip)
{

}

Will that work for:
John Smithers 2031 West Alberta Street Sioux Falls South Dakota 65565? What will be in zip? :icon_rolleyes:

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

... the whole marking as read and new posts since last visit features are standard vBulletin,

Maybe they broke something themselves...

I'll snoop around. :)

Anything yet? Is there more information I can get you?

Do you need me to let you know when I leave the site and stay away for half a day at least so you can look at my dates & times and compare when new posts come in?

Do we need to connect offline so I don't change time settings by logging in to help track this down?

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

I'm in Rapid City - opposite side of the state from Sioux Falls. The better side side of the state.

The Wall Drug side of the state? I hope that's not what makes it better!! :icon_lol:

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

I have an implementation here: http://sourceforge.net/projects/kwaymerge

I'm sure after 2 1/2 years the OP will be ecstatic to hear that. :icon_rolleyes:

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

Are we supposed to guess which line out of 95 the error occurs on? We have slightly more than a 1% chance of that... :icon_wink:

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

Set X=x+20
Add 20 to X
Increment X by twenty
20 is added to X

In other words, any way you want to word it.

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

That's terrible... :confused:

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

Use the remove() function. You have to find out where the file is and pass the path to the function.

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

oh sorry i forgot to mention that it suppose to print out the names and scores in ascending order.

You did? Here's your first post. Read the first line:

When it prints it does not print the numbers and names in ascending order like its suppose to do and i have no clue why it doesnt. This is for school and this is the book we are using in class: sixth edition-starting out with C++ early objects. We are as far as chapter 10-pointers this would be program challenge problem #2 in the book.

Also, you don't need to quote your entire message to add a single line.

Lastly, your code is a mess. See this to clean up your code so it's readable. Pay attention to the indentation section. I for one don't want to decipher the code.

All I can suggest is look at your sort function and print out values during the sorting to see what is happening. Or, reformat and post the sort function and explain in full what you expect and what is actually happening.

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

1) don't use eof() to control the loop.

Why not? Don't you think an explanation would be more helpful rather than simply dictating to posters? It might actually teach them something.
phvan, see this ( feof() is identical to .eof() .

2) Read the file line by line using getline(), not >>.

Again, why not?
phvan, >> will only read up to the first SPACE so will not read an entire line, nor a multiple "sylable" name.

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

Are you in fact asking us to tell you what you are doing wrong? If so, how would we know? We aren't the Psychic Programming Forum.

Have you considered showing us what your code is and explaining
1) what is actually happening and
2) what you want to happen?
Like the post titled Read Me: Read This Before Posting says? (note the title -- it's important) Please do so and we can probably cut this from a three day guessing game to a 2 hour solution session.

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

CHARACTER ST*(*) is just a string to be converted;

String like a C++ string or a C-string? Be specific.

CHARACTER ST1*10 is used to save some characters which length is less than or equal 10.

I was asking what the declaration means, not how they are going to be used. We need to know the language definition.

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

didnt got ne more prgms to get the if and else part executed at the same time...
give it up .. it can never be done....


can u ever play football and vollyball at the same time????

maradona was an exception:P

What???? You need to read this -- it's part of the site rules. In other words, this post breaks the site rules. In fact, many of your posts do.

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

wish i was good at this! humph!!

You will be. Hooray!!!

Just takes practice...

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

Your compiler lets you get away with it, but in C you should generally stick all variables before any code...

Not generally. It's always. :icon_wink:

BTW. What happened to your nice [[I][/I]code[I][/I]] blocks? (Only use [[I][/I]inlinecode[I][/I]] for a single line of code.)

There are no nice code blocks. I fixed the CODE tags and there's still no indentation.

Caitlyn, please read this about code formatting. This will do various things:
1) Make your code more readable. You will be able to follow the code better
2) Help us read the code to give you better help
3) Help you get a better grade because your instructor will be able to follow your code
4) And it will help you get a job in the field if that's your desire (seriously)

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

It's been too long and ForTran has changed. If you explain what the arrays mean in FTN, we can probably give you more exact answers.

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

This is still happening... Done at 3:30AM and missed posts thru 11:00AM

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
display menu
input choice
while choice != quit
[
    computer = random-value
    call function TestForWin"  (returns 0 for computer win, 1 for user win)
    Output message based on the return value
    output menu
    input choice
]
exit program

function TestForWin"  (parameters computer and user choices)
[
    winner = (decide who wins)
    return winner
]
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How can in "play havoc" when 0.0000517 is almost 0.00? They are essentially the same. I suggest it's how you are using 0, not the fact that it's a minuscule number.

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

Look carefully at the flow of your code

Display menu
accept input
While bad input
{
    accept input
}  // end of while

if (quit)
{
    quit
}  // end of if

loop forever
{
    do stuff
    never enter [B]input[/B]
    never break out of loop
}  // end of forever loop
done.

That's what I see. You never are asked to enter another function.

When you added outputs to see what variables had what values, what did they tell you?

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

I recommend you use whatever function you decide to use properly -- which includes setup of variables. If you don't know what you're doing, beware. If you know what's going on, no problem.

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

I disagree. If your oven has a conveyor belt build in to it, it would be possible to eat the first part of the pie, while the other part is still in the oven being baked. :)

I dare you to try it! :icon_twisted:

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

My only problem with Registry First Aid is the lack of ability to look at only a portion of the errors. Like when you get 400 errors you can't single out a certain type, nor can they be sorted. Other than that, it works well.