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

Bingo! I told it was for a mod, Well it was about you. I tried up-votes two times(Not consecutive) and they just disappeared... It only happened with you so-far...

The system obviously doesn't me to get a swelled head. I'll start leaking brain all over the keyboard...

And tried up-voting two of your posts today, it worked.

Yay! Bigger rep numbers! I feel the swelling!!! :icon_mrgreen:

jonsca commented: That's just a pimple.... +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I've found the UP/DOWN arrows to be flaky at best. Though they don't disappear for me most of the time, when I click one half the time nothing happens.

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

who told you that 121 is a prime number oh please

If it did anything useful, your program would...

besides the code i have written works perfectly fine and i have tested it a hundred times

Really? I entered 130 and it output 32. How is that useful?
I added a cout to display the prime numbers it calculates and got

Enter thenumber till the check should go200
11  13  17  19  23  29  31  37  41  43  47  53  59  61  67  71  73  79  83  89
97  101  103  107  109  113  [B]121[/B]  127  131  137  139  [B]143[/B]  149  151  157  163  
167  [B]169[/B]  173  179  181  [B]187[/B]  191  193  197  199
50Press any key to continue . . .

Where's 2, 3, 5, and 7? What is 121, 143, 169, and 187 doing in the list? And what the heck is 50????

It runs fine, but the answers are completely wrong... Therefore it's useless.

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

Since structures and classes are nearly identical...

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

I think you're going to have to wait for someone from India to join the board that can help since it seems only India teaches with outdated equipment and tools. The rest of the world left Turbo-C over 10 years ago.

And Narue wasn't joking... :icon_wink:

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

Again, is number to be used in math? Are you going to add it to anything? Make it a string and see what happens...

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

Sure, they'd have to provide a driver (that was included in my 20 line estimate :) ).

We can't even get them to post with CODE tags and properly formatted! How are we going to get them to write a driver, too? Most of these people think a driver sits in a Toyota, not a computer. :icon_wink:

AndreRet commented: lol, indeed +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

it is simple:

Then why make it so complicated? How about:

#include <iostream>
struct Point             // use proper formatting
{   
    int X;
    int Y;
} ;
typedef  Point* PointsArr;

int main(void)                      // use proper main() footprint
{
    PointsArr test[10];             // hold 10 points
    for(int i = 0; i < size; i++)   // use whitespace to more easily read the code
    {
        test[i].X = i * 2;          // use whitespace 
        test[i].Y = (i * 2) + 1;    // use whitespace 
    }
    for(int i = 0; i < 10; i++)
    {
        std::cout << test[i].X << " " << test[i].Y << std::endl;
    }
    return 0;                       // end main() properly
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Try outputting the value entered immediately after you input it to make sure what you typed in is actually in the value.

By the way, you have phone as an integer. Are you going to do math on it? If not why make it an integer?

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

But then again, in code snippets you are supposed to post correctly working tested code to begin with. Not broken code that needs a web-based compiler to fix.

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

Hello, I have a strange problem and I need some help... I am working with a project that the compiler create a txt file and save the informations of the user as the user enter...

So far, so good.

The program create only ONE file and overwrite eatch time... The problem is that the compiler create a new TXT file and isn't save the details into the data.txt but on that txt file that is invalid encoding... Any ideas about that??

Explain your problem clearly... Where in the code is this happening?

Also the program must have a rent movie option and a return movie, if the user rent a movie the program will just subtract -1$ from the account and rent the movie, and print the current balance and if user now want to return a movie the program will just print out that the user return a number of movies end print again out the current balance of the user.... ( I thing this is ok I don't really need help with the return movie selection..)

So what do you need help with? What is it you can't do?

And at the end the program will search by the option phone_number or last_name and print out all the information of the user....

Again, what's wrong with the code? What does it do wrong? And where?

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

Look up srand() and rand() functions.

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

Did you read WaitP's post above you? It applies to your post as well :yawn:

And you better to help someone instead of explaining rules...

No regards for you.

history & ganeshchincholk, I'm glad you two could cheat off each other. This thread is exactly why we have those rules which you both violated. Kudos.

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

Nowhere do you properly test for valid input.
In the loop

for(j = 0; j <= strlen(input); j++)
{
    if(input[j] == ref[i])
    {
        run = 1;
    }
    else if(input[j] != ref[i])
    {
        run = 0;
    }
}

you give it a try, but if the last character tested is good, you set the entire input to good. Follow that code with pencil and paper.

In the line status = scanf("%s", input); you
1) return a status but never test it where it does any good.
2) read only up to the first whitespace, so an input of "2 A +" only reads "2".
3) Read this.

Here's the secret to solving most of your errors immediately: printf() !!!
Print values to see what they are at key spots in your code. Displaying input immediately after your scanf() would have shown you what your major problem is.

Also, proper formatting will help a lot in readability. Concentrate on better indentation.

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

That it could contain anything?
The reference I'm using says strcat will append string2 to the end of string1, so we add a string terminator to the beginning of buff, to make sure strcat will write from buff[0], even if other elements contain a terminator. So yes, buff[0] = '\0' is necessary.
Guess I could figured that out : )

And you did, too! :)

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

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sudoku in C++. The program works but how do I check the minisquares? Please gimme a function. :( Pretty please?

"Please gimme a function?" I don't think so. We are not a coding service to help write your code for you.

Figure out what the indecies are for a minisquare. Look at the pattern in those numbers. Then write your code based on this new knowledge.

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

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your compiler should have a graphics.h file (not there in Dev C) and you can find the programs over the internet or in some authors book.

graphics.h is extremely rare. I know of only 1 compiler series that had (emphasis on had) one. So don't expect to find it, especially in current compilers.

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

If "malloc() doesn't guarantee anything about the data it returns a pointer to" what do you think that means about your buffer?

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

You know, if you have a compiler you can just type in the code and see for yourself. Rather than say 'what would the value be' write the code and output what the value is. Then you'd know for sure in minutes rather than 3.5 hours and counting.

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

Why not explain how to format the code properly so the OP can find his own mismatched braces? :icon_wink:

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

Turbo C++ is showing declaration syntax error with this statement. Help.

void main()
{   test s;
    int ch,roll;
    char name[30],choice,join;
    clrscr();

It is showing the error with the ' { ' . I have used proper header files and stuffs, and this is just a part of my 700 line program.
I have used only one void main() , and i have closed it too. So, it cant be the problem.
Just this error to go with and i complete my project. :sad:
So, any idea? :S

Nope.

For one, you should not use void main() at all. See this.

For two, there is not enough info for us to even venture a guess. It's very likely because of something above main()

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

Start a new thread with a proper question:

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Just load the new string into Text1.Text

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

#1) What zeroliken said
#2) It's C++. Why are you using the terrible and dangerous C function gets() ? Use getline() .
#3) cin is your problem. Reading an int leaves the NEWLINE in the input buffer. The solution has been explained many many times on this site -- do a search.

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

Hello,

I do not understand the following parts in bold - how it works, what is is for..etc. I'm not following the book's explanation..

It called a prototype. If you use the function (line 17) before you define the function (line 30) the compiler does not understand line 17. Therefore, you add the prototype to tell the compiler "when you see this function, it's used like this way -- it will be fully defined later".

It's like a trailer to a movie. Lets the compiler know what it's about.

I'm also not sure why it's called "parameter" here. Like I said - basically, I can't figure out why it's there and what it exactly does. I would appreciate any help.
Thank you

Why what's a parameter? Maybe it's called that because that's what they call it. Like why do they call it an airplane -- because that's what it's called.

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

It's because the input you are probably using, by definition, stops inputting at a SPACE. Your error is not in the code posted.

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

You've been waiting 4 years to get back to this program?

No wait... First post -- resurrecting an old thread -- for no reason other than stating something doesn't work, but not explaining what doesn't work.

FAIL!!

Start your own thread and ask a real question.

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

can someone please tell me how am i suppose to start my program ?

Open the editor in your IDE
Type in the program you designed to solve the problem.

That's how to start your program.

i have 20 integers (1-20) the user will input what number should start and the count interval . its a bit confusing

What's confusing about it? If we don't know why you are confused, how can we help you understand?

You need a FOR loop. Look it up.

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

Where did you test the characters in your string to see if they were all digits?

WaltP I have search on website before I post my problem, it's a little bit of confiused...

http://www.daniweb.com/software-development/c/threads/404547
http://www.daniweb.com/software-development/c/threads/386198
http://www.daniweb.com/software-development/cpp/threads/306683
and so many more...

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

Create a function to read the numbers.
Search this site for ways to read characters in number inputs. It's been answered at least once a month for years.

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

Do any of your strings, including engine, have a trailing newline?

Add output statements at key points in the program to display important values. Like first, last, middle, string[middle].

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

Python doesn't teach bad habits.

No language teaches bad habits. Languages simply allow bad habits if the user is taught poorly or is a hack.

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

4 resurrections... Great.

looping statements
if n=5, output
********
******
****
***
*

plz answer :(

... and with a gimme the code question -- how lazy.

Closed.

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

Search the string for the _ and replace it with whatever you want.

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

Since he hasn't logged in since making this thread, and the only responses being made are juvenile and worthless, this thread is closed.

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

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I can think of two ways to do this. (Also, get rid of the return j. It returns from the main function and exits the program. Get rid of the printf(j) at the bottom. Why do you have it?)

There's a third possibility that makes even more sense...

First: using arrays.
Since you're using characters 7 lines tall, create 7 arrays each about 80 bytes wide. Actually, I would take the width of your longest character (about 5), add 1 for a space (5+1=6), multiply by 3 since you have 3 characters (6*3=18), and add 1 for a trailing 0 (18+1=19). So you could create 7 arrays of 19 characters. Or a 7x19 matrix. Then, instead of doing printf for every character, use strcat. THEN, when you're finished strcat-ing all your characters together, do a printf for each array.

There's too much computation going on for such an easy problem.

Second. Use a console cursor moving function. If you're using Windows, check out http://www.daniweb.com/software-development/cpp/threads/22498

Otherwise, in Linux (which lets you use ANSI), use something like this:

char escape=27; int y= 1;int x=7; 
//{1,7} will park you at the upper left corner of the second character
printf("%c[%d;%dH",escape,y,x);

Completely non-portable and non-Standard therefore not recommended.

Make a 2D array for each letter. Rather than

printf(" 000\n");
printf("0 0\n");
printf(" 0\n");
printf(" 0\n");
printf(" 0\n");
printf("0\n");
printf("0000");

make an array for each letter:

char *letter1[] = { " 000  ",
                    "0 0   ",
                    " 0 …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That completely depends on what is proper and improper results.

Asking us to read 359 lines of inconsistently formatted unexplained code to figure out
*) what the program does
*) what the program outputs
*) figure out with no clues what the proper output should be
*) where the problem is
*) how to fix it
is a little above and beyond the call of volunteers.

After 53 posts, you should know better than this.

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

And where do you state you were in HS? You're the one that mentioned "the author is currently working at Microsoft" with no timeline, explanation, etc. to let us know you wrote it years before.

Who's the moron now? Maybe you should have left a 5-year-old thread stay buried.

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

Is there a simple way to catch the char input and ask the user to fix his choice, similar to the way my program handles a user entering a number that isn't in the menu?

Read all your inputs as strings. Test the string for all digits. If correct, convert the string to a value and continue.


[minor rant]

Be gentle. I'm a noob. ;(

This is and always has been one of the most obnoxious requests we get. What makes you think we can't tell you are a noob? Doesn't your question already implicitly state it? :icon_rolleyes:
[/minor rant]

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

Excellent question! Yes, you are correct.

Since the random value will be 0-5, that will equate to a roll of 1-6. Your output must compensate for that value shift.

I was hoping you'd come up with that yourself. :icon_biggrin:

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

First is contact the person to understand why.
If you still disagree, flag the post as bad and explain why you want a change.

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

You say that as if the code isn't already completely non-standard and clearly based on libraries supported by Turbo C. Just say "use getch()" and be done with it, since this is a time when getch() is warranted. :icon_rolleyes:

Didn't look at the code closely enough (if at all).

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

Standard C cannot do what you want. Input is only accepted using the ENTER key. You have to go into non-standard specialized code that most compilers do not contain.

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

If you say so. Although they might be able to explain why if you are unable to grasp the comment. Or they could give good rep to counter the bad if you're argument is sound.

And if you go through the right channels, the rep can be reversed/removed.

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

We can't help you overcome any problems when we have no idea what the problems are.
So far you have given us no information and you have not asked any questions.
(adding a ? to the end of a statement does not make it a question)

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

1) use an array to add up the numbers ( int roll[6] )
2) calculate your random answer (do not add 1 giving 0 => 5)
3) use answer as an index into roll[] and increment ( roll[answer]++; )

At the end of the loop, roll[3] will contain the number of 3's "rolled".