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

The google search you posted did not have anything related to programming.

It actually did answer the question AD thought you asked. Which was more than I could do because to me your question doesn't make sense. What does the system() command have to do with the size of the command prompt?

Do you think I'm an idiot?

Not necessarily. But when 95% of the new posters here are, you unfortunately fell into that category. But then, if you rephrase your question so we understand what you are looking for, all doubts will be removed.

PS: Are you, maybe, talking about the command window -- not the prompt?

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

The 4000+ guests! :icon_mrgreen:

~s.o.s~ commented: :-) +23
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Where are you having the problem?
What does the program do wrong?
What makes it wrong?
What should it do instead?

When asking for help it's necessary to explain the problem, not just toss 3 ambiguous sentences together without punctuation making it hard to decipher your meaning.

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

You cannot compare character strings in this manner. You need to use one of the string functions.

You probably want if ( strcmp(argv[1], "e") == 0 )

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

I had been thinking along those lines, but probably way off with...

if ( choice != "y","Y")

Yes, you're off. You have to test each character individually. Something along the lines of if ((n < 5) || (n == 10)) which is TRUE if n is 4 or less OR equal to 10

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

Or add output statements to display values as the program runs with the location within the program.

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

First, get rid of the clear screen stuff since you cannot make it portable and is not part of standard C++
Second, get rid of the GOTO statement and use a while loop instead
Third, you say you want the "second out put replaces the first" so change your output statement to cout << h << ":" << m << ":" << s '\r' <<ends; \r will move the cursor to the beginning of the line just output.
ends is the same as endl except it does not go to the next line. It basically just forces the output to the screen.

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

Alt-PrtSc to copy the active window to the clipboard
Ctrl-V to paste it into Paint.

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

Oh, yeah, I'll be the first to admit, Turbo C is preferable. but it costs $$.

My ghod! Go to the f'n links and download the FREE Turbo C Compilers I linked to!!!

Stop posting crap -- check your facts!

you just can not physically maintain an assembly line running dos.

Maybe you can't, but it's obvious others have the knowledge to keep older O/S's running. They seem to be doing it.

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

http://www.digitalmars.com/

you have my sympathy.

Why would you even bother mentioning a piece of dreck like that? :icon_rolleyes:

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

The problem's in your code; without seeing your code it's a bit hard to see where the problem is...

No it's not. Almost every error is ... error C2664: 'carddeck' : cannot convert parameter 1 from 'int' to 'int []' You are passing an integer in parameter 1 of carddeck and the function wants an integer array. Read the errors and look at the lines specified. Then look at the variable types and find the mismatch.

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

Use one of these compilers:
Turbo 1.01
Turbo 2.01
Turbo 3.0

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

what about lithp?

Not as old as ForTrash, and definitely not a universal language.

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

So if I write:

No estimate(data, n, m, &xms,d); data, n, m, d have no value for (i=0;i<m;i++) m has no value printf("\n%f, d[i]"); Improper syntax. Try printf("\n%f", d[i]); instead.

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

im building a telephone directory. and the code is given below.
i am using file system to store the record which i get from the user. and then i should be able to do searching, deleting, sorting and other default telephone dir functions. so far i have been able to get the input from the user and store it in a file, retrive the records from the file into a binary search tree and display the contents of the binary search tree.

there are some bugs in this program. bugs i guess are in the building the tree and displaying the tree. i would also like to display the menu after i call the inorder function which i tried but in vain.

If you don't know, how can we help you? We didn't write the program, you did.

//edit: i fixed how to display menu after the inorder function. :)
//the bug is.. wen i try to display from the tree, some records are displayed twice.

i used diffrent compilers (g++, bcc32, visual c++, turbo c++) and i got different outputs.
can anyone suggest a ansi standard compiler.

All of the above. If you are really getting different output, you have some major problems in your code. Narrow down what the problem is and we can help you fix it.

i am not sure if my code is an optimized one. using a binary tree a good idea? or sud i try to do direct …

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

Old? What does that make ForTran??? :icon_twisted:

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

the first number .. ok.. i see.. i thought it would move to the next number the next time i open the file... but i'm guessing it will only move to the next number while the file is open and if I close it, then it starts over...

Exactly.

so then how do i get it to define my variables in a way that i can get a loop working...

It's already defined.

i mean do i have to create a month 1, day1, month2, day2.. kind of scheme or is there a way to get it to re-input the variables with the next number every time the loop runs? i'm really lost here.

Maybe you need to step back and write a test program that ONLY reads the file and outputs the data read. Should only take a few minutes and it will explain a lot (I hope).

Key point in programming:
If you have a task and there are 3 things you don't quite understand, don't write the program in one shot. Write 3 programs one at a time exploring each of the things you don't understand. Only when you understand each separately, put them together to solve the whole task.

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

then do i need to close the file outside of the loop where i define x and then open the file inside of the loop to define month and day?

No. You need to think about what opening and closing a file means. When you open a file what's the first thing to be read?

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

Let's look at your program.

Open input file
Start a loop up to 20 times
    input from the file
    close input file
    process input
end of loop

So, since the input file is closed the second time through the loop, your input causes an error which you never test for. Then you just blindly process whatever is in the input variables (which is the values from the first and only valid input)

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

What are you trying to accomplish with this statement? if (month=12, month<=3)

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

Creating a unified rating system does make sense, but it would take awhile to code, so is more likely something a month or so down the line. There are a couple of things that I want to accomplish first, such as adding a 'Flag Bad Post' link to the blogs and code snippets.

But is it something that needs to be done? I'd recommend getting other input as to whether the time should be put into this. I'm not convinced.

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

could any 1 tell me why this code isnt working right??
two.txt is not wriiten good...

Because it's written poorly?

It's your job to tell us
1) what the program is supposed to do
2) what exactly goes wrong
3) why it's wrong
4) what is supposed to happen instead

I assume you haven't read Read Me: Read This Before Posting yet...

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

Not bad, I didn't realize that function existed. I thought you had to write your own!

If the purpose of the program is to teach you how to calculate an average, you do need to write your own.

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

Ive sorted that problem but how can i read the persons name and write it to a txt file and then read the company name and write it? Also i need to output a " to a text file how do i do this?

Maybe by having the company name in the input file? And if all you are doing is copying the file, why do you need to output a "?

Maybe you need to explain what you are trying to do and not give us small pieces of the problem that don't make sense all by themselves.

Have you read Read Me: Read This Before Posting yet?

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

owh i get it but hwo about in million
can u make me some codes of that like this

Can't you write ANY code at all? Do we all need to do your homework for you?

This is lazyness, but i have nothing to do atm so....

"... so I'll write it for you so you can pass you class and not have to learn anything but how to beg for answers." Is this basically what you meant?

your really starting to sound like you want someone to do this for you with no effort...

Starting? I thought his second post showed this. And he confirmed it absolutely with

so what is the complete of that code...? and how about in roman numbers...? tnx

So far he has posted absolutely no code and has gotten at least 3 programs in response. C'mon guys, this is not a handout clinic here!

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

Change cin >> variable to cin.getline(variable) And use full words in English as the Rules specify. You did read them, didn't you?

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

It's because you can't create a buffer using a variable as the size:

int buffer = 11;
	char name[buffer];

You need something like:

#include <string.h>
#include <stdio.h>
#include "input.c"

#define BUFFERSIZE  11

FILE *playerdata;

int main(void)
{
	char name[BUFFERSIZE];
	printf("Please Enter Your Name\n");
	printf("Maximum Length 10 characters\n");

And what if her name is Elizabethany? :)

midimatt commented: Thanks for making me realise the problem :) +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Don't try to do it all at once.

First, check for the negative sign. Make sure there is only one and it's first.
Then check for one decimal.
Last, check that there are only digits, decimal and negative signs in the input.

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

When are you going to learn to explain what you want in understandable terms? "I want to call (3,1) then (3,13), then (3,34).........." means what? What does "call" mean?

"How to declare 3 is the first than 13 is second?" is also meaningless. The first what? The second what?

Give us a full explanation of what you are trying to accomplish.

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

We need to see code in order to figure out what's happening. Isolate the problem by creating a small version of the program that exhibits the same problem.

Copy your program and start removing sections of code you know does not cause the problem -- piece by piece. When you get it to a few lines, one of two things will happen:
1) you'll see the problem
2) the code's small enough to post

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

abhikkumarbasu, it would really help if you'd read the threads you are responding in. He very definitely said he's using DevC++.

And I've seen other posts that you've offered the exact same advice as the post immediately before you -- and hours earlier.

We appreciate you desire to help and fully welcome it. Just try to be a little more observant so you can help people with the best advice.

add getch()

AD?!?! Really? Don't you mean getchar() ? :icon_wink:

Ancient Dragon commented: good catch :) +24
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You're looking for kbhit() , the fraterna; twin brother to getch()

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

When you post a request for help, you need to tell us what's wrong. Don't just tell us there's an error and expect us to look for the error.

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

Could it be there are no input statements in your code?

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

Also, please read this series on scanf() , especially the character and string entries.

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

Did you fix numbers?

Since you changed your code, you might want to share it with us.

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

John is correct on both counts. Change that nested IF into a switch and it'll be easier to read.

I see a while statement in case 1: -- what is that supposed to be doing?

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

please help me out how to solve this poblem...

Please help me out how to solve this problem....

Can anyone help me out...

Please help me out how we can solve this problem...

Jeez! Stop begging! Aren't we trying to help you? :icon_rolleyes:

[edit]The particular thing that caught my eye was a directory listing.
To me this says that you may keep reading non-existent data.

[aside]This kinda thing is pretty much in the ballpark of why I dislike the "read to eof" idiom of input gathering.[/aside]

Dave is referring to the line while(!myfile1.eof()) in your code. See this for an explanation why it's a bad thing to use -- feof() and .eof() are identical.

And after you fix the .eof() , maybe it's time to post your current code. I assume you've made changes.

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

Guys, guys, we're supposed to be 'experts' here! :D

#1: You are using a for loop but your exit criteria of the loop depends on counter and limit. Your instructions say "when the user enters a negative number or zero" and counter has no bearing on the exit.

#2: After you input your value, whether positive or negative, you process the value.

Recommendation:
#1: Try a different type of loop. There is a better choice, although for will work, it's just a little clumsy.
#2: Is there a better place to input the value within the loop so it doesn't get processed?

Dave Sinkula commented: Good clarification. I'm trending terse lately. +13
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And WaltP, I will remeber to code with mega amounts of whitespace!!!

Please don't! Use appropriate amounts. The following is just as bad as none :icon_wink:

if   ( a  ==      b)
{
                      j    =      alpha      *      89;
                      cout        <<        "Answer #1"           <<
                                               j   <<            endl;
             }

:icon_twisted:

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

What values are the variables going to have if there were no numbers in the given range? Test for those values before you output the min/max.

Hint1: look at the special value you used.
Hint2: what does testing the last value entered (x) when you output your results do for you?

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

Problem 1, (lines 37 -43). The program will correctly count the number of integers in the .txt file and will create the correct size array. But it will not list the actual numbers from the file. For example, input file "num8.txt" has 8 integers from 1-8. So an array of length 8 will have 8 integers in various order. How would I get each integer to sort it? I thought of using the following code...

In the while loop you need to load the value just read into the array. What you are doing is reading all the values in the while, then loading the last value read into the array with the for loop.

Problem 2: When compiled the output will all be sorted correctly on any file with 64 integers or less. The program crashes with files that have larger numbers of integers. I can not understand why I would run out of memory as I have declared all int values as longs.

The size of your variables have nothing to do with the number of values in an array.

You've declared

int main()
{
  long count = 0; //counts the number of numbers in the input file
  long numbers[count];

You just declared numbers to be an array of 0 values. Are you getting a warning or error on the long numbers[count]; statement?

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

(I'll accept any reasonable solution to handling the first two numbers)

So nice of you :icon_wink:

This isn't working for me, and I'm not sure how to fix it or how to get the average of only the last three inputted numbers.

Is there something about explaining why you think it doesn't work that is just lost on new posters? If you were going to help someone, wouldn't you want to know what's wrong? :icon_rolleyes:

There's an obvious error in this code. Let's assume x=3:

num1 = x;        // num1 now = 3
       num2 = num1 + x;   // num2 now = 6 (3+3)
       num3 = num1 + num2 + x;    // num3 now = 12 (3+6+3)
   
       cout << num3/3 << endl;

How is this averaging anything? Think through how to average 3 numbers again. Maybe do it on paper to get the process figured out step by step. Then translate those steps into code.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
#include "stub.h"
int main()
{
   int x = 0;
   int highest_pos = 0;
   int lowest_pos;
   int counter;
   int highest_neg;
   int lowest_neg;

The values lowest_pos, counter, highest_neg, and lowest_neg start with unknown values. They could be 0, or 165432343, or -8554545487. You need to initialize them to some appropriate value.

Keep in mind if you initialize lowest_pos to 0 what will happen when you execute

if ( x < lowest_pos && x > 0)
    lowest_pos = x;
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I repeat:

First, think about what the program is supposed to do. What has to happen for one equation? If there's a 'get another' something, there's a loop around that something. If there is a 'calculate another' something, there's a loop around that too. BUT -- do you need one loop, or two?

Use pen and paper and write an equation to calculate. Below that, write down the variables you've defined in your program. Now, verrrry slooooowly do the calculation, one small step at a time filling in values for each variable as you go. Think in terms of the ifs, the switch, and the loop. What operations do you do more than once? In what order?

So do an equation completely by hand, step by step, and write down each step. Then look at those steps carefully. Then write another and solve if by only following your steps -- this time without thinking. If you get the correct answer, convert your steps into code.

And thanks, niek_e. Maybe I should have just written it for him, too. Save you the trouble :icon_confused:

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

I am so confused now! I cleaned up the formatting, fixed the indenting, rid of some of the 'if' statements , is it better?

Much!! A couple problems but much better.

The program will not calculate at all so I really did something wrong. I am a bit thicke and this the 13th straight hour I have been working on this is getting to me.

Can you in great detail (so I can understand) tell me what direction I should go?

You ain't gonna like it. Here's the direction you need to go -- think! See I told you :icon_wink:

OK, so you moved your loop above the switch. When is the switch useful? After you've input all your numbers and operators? And since you have no way to exit the loop, how do you expect to get to your switch?

First, think about what the program is supposed to do. What has to happen for one equation? If there's a 'get another' something, there's a loop around that something. If there is a 'calculate another' something, there's a loop around that too. BUT -- do you need one loop, or two?

Use pen and paper and write an equation to calculate. Below that, write down the variables you've defined in your program. Now, verrrry slooooowly do the calculation, one small step at a time filling in values for each variable as you go. Think in terms of the ifs, the switch, and the loop. What …

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

Ok, here is what I have now. I am still getting errors when it comes to calling the function and passing the values.

Such as? :icon_rolleyes:

Psychically debugging code is hit or miss proposition. Mostly miss. Unless you give us information, there's not much we can do...

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

First thing -- please use better formatting. You have too much indentation and not enough whitespace in your code. Look at your post above. Notice how it's hard to follow?

If you are going to use a switch() statement, why are you using all those if statements? Use one or the other, no need to use both.

You are using while(1) for your loop. When will it exit? Put a condition that meets your exit criteria and you won't have to test for it using an if in the loop.

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

You need to look more closely at where your loop is. Your code:

input a number
test your operator (it was never entered)
    process the operator
start a loop
    input operator
    if operator is illegal 
            output error
    else  input number
end loop
...

You never test any operator and process the result except the one you didn't enter.
Once you start the loop you
1) never exit the loop
2) never process an operator or the numbers

Think about where your loop should really start, and what should cause it to exit.

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

With todays compilers, you don't. Those headers are no longer used.