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

Try outputting the values you input to see if they are correct.
Since you are probably using, as DeanMSands3 supposes, Turbo (I'm sure he's correct) find out what the largest integer is you can have in your compiler.

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

How to start...

Same way you do with any program
1) decide what you want to make (without graphics)
2) write down how the game works
3) write down the steps it takes to play the game
4) expand each step until you can't expand it any more
5) write code to do one thing and TEST FULLY. Do not continue until this part works.
6) add one more thing to it (see #5)
7) continue until the game is complete.

and how to end?

Stop coding.

what kind of game can i try to make?

Something without graphics

which IDE to use ?

Whatever you want

i cant run <graphics.> header file for graphics in any IDE. How to configure init() = (&gm, &gd, "C:\Tc\") in Turbo C. How to use simple code and not very complex code.

Don't. You don't need graphics.

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

a C file always require a main function to execute as in the case of multiply.c

Take another look at test1.cpp. main() is right there!

After changing test.cpp to test.c, add multiply.c to the compile line.

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

What happen with your brain ?

Your post -- thinking you can use graphics.h in Dev-C and were surprised you program blew up...

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

I can't find any information and how to return a string without using pointers.

So use pointers.

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

I have worked alot on graphics.h after including it in dev C++. in Dos Box your program will crash(without undefined reason) again and again(it is my personal experience).

My brain hurts! 8(

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

What numeric system do you know where 1 + 3 = 5?

It's obvious -- for large values of 1 & 3 and small values of 5! ;o)

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

Concentrate carefully on this loop:

while(atSymbol(emails[i]) == true)
{
    i = 0;
    i++;
    if(emails[i] == '@') break;
}

1) In the while, aren't you looking specifically for an @?
2) Is the break really necessary with the proper while statement?
3) Comment each line to explain the reason for the line.
4) Use pencil and paper and execute the loop to see if it does the correct thing.

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

ok waltp as u say i wont use gets() but using gets() its easy to read a string right...

Using a bulldozer to open your front door is easy, too. It that the safest tool?

... so what else can i use scanf????

here -- here -- here
Actually read the help that you have been given.

and perry 31 i tried ur code its producing wrong output but does not show any error

And this is one reason why we don't give away free code, as well as the reason it's called cheating... YOU don't get the grade, and THEY don't deserve the grade on your work.

I_m_rude commented: damn funny comment! +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'm looking for valid characters, is that what I need to put in the while loop statement?

BINGO!!!

Of course, you also have to correctly handle the cases when no valid character is found.

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

Think about how you want your breakpoint to work.
What happens when the breakpoint is activated?
What does the user get to do when your breakpoint is activated?
How do you want to continue from the breakpoint?

Figure out all the ins and outs of your breakpoint concept.
Once you have that designed, then you are ready to code it.

As for int 3, forget it. I doubt strongly it's what you want.

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

And what part of "*don't use gets() *" is so difficult to understand?

If you want further help, start using the help you've been given. Otherwise, why should we bother?

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

What's the error at i=n;?

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

Repeat#1: You are looking for something specific!!!

while(i < emails.length())
while(s > 0)
while(e != emails.length())

Not one of those while statements look for anything specific

Repeat #2: Each loop should be only about 2-3 statements

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

1) You are still using a FOR loop
2) You are still nesting your loops

How about:

While Loop to find the @
  End of loop

From @ position:
While loop to find beginning
  End of loop

From @ position:
While loop to find end
  End of loop

Do NOT use while(true), that is not an appropriate condition in your case. You are looking for something specific.

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

There are a number of issues with your code. The first one is merely for clarity and speed. Basically the isValidCharacter function can be 1 line:

For speed, yes. Clarity, no. IMO, your 1-liner is not as clear as the original. That's not to say the original is clear, either. It really isn't.

In my years of programming, I've found you program for clarity or speed. Rarely can you program for both.

Here's a full listing of my code with lines added for debugging.

Why? It's going to take longer for the OP to compare your code with his to get any real understanding (he's new, remember) so it would be easier just to replace his with yours. That's not what this board is about.

And a finite state machine??!?? He can't even parse an email! How is he supposed to program a finite state machine? And what would his instructor say about it? ;-)

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

First off, you should use WHILE statements instead of FOR statements. You are not iterating through the string a set number of times, only until a specific condition is met. This will also let you process the string in 3 distinct segments:
1) find @ and end this loop
2) find beginning and end this loop
3) find end and end this loop
Each loop should be only about 2-3 statements

You have the loops interleaved making it harder to follow (also your indentation is inconsitent also making it hard)

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

I repeat:

When you enter a negative number, what do you do with it? You process it as if it was a salary.

... what do you need to add to the code to see if a negative number was entered?

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

No idea what's best. That depends on what you like. And what you know. Since we are ignorant of both, what can we say? Craps is a game. So is Halo. Are they great? Depends.

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

1) void main()
2) gets()
3) "not producing correct output" -- Can you be less vague? Direct answer: There's something wrong then.

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

will this work sir????

What part of

you need to use an intermediate integer.

int a,b,temp;

temp = a
a = b
b = temp

did you not understand?

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

find the min and max nodes a quad tree

Are you missing a verb or something??

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

No it's not legally binding. Yes it's possible.

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

So what do you need to add to the code to see if a negative number was entered?
If a negative number was entered, do you want to process it as a salary or do something else?

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

When you enter a negative number, what do you do with it? You process it as if it was a salary.

After RATE = 0.06, you loop back, to get a new salary, but RATE is still 0.06. Is this what you intended?

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

You probably could but ModernC++ completely derailed your thread proving his prowess at programming but not his aptitude for aiding amateurs.

Start a new thread after reading Read This Before Posting A Question. Then we can get back on track.

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

Games.
Mastermind, Craps, Hangman, Lingo....

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

I meant that next time I won't bother to help. I explained that the line is wrong and you completely ignored me. I won't waste my time on your next problem.

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

Sorry I bothered trying to help.... I'll try to remember not to next time.

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

Right.

You'll have to think through all the possibilities, and/or get a format dectription of the packet to see if the URL is always followed by a certain type of byte (non-character for example)

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

Would you believe

Unfortunately, I do believe it. Lucky for some programmers deprecated only means "you shouldn't use it" rather than "don't"

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

Well, your file contains 2 numbers that do not have '.' in them, and the code has an error message that says "Error - no '.' detected.". Therefore I wouldn't expect the file to work.

Making the assumption there's even more you haven't mentioned (like there's a real bug in the code) I'd suggest the following things:

1) format your code consisently. It's very hard to follow with the haphazard indentation you're using
2) add output statements to follow your code as it executes. Then you can see where your code deviates from what you expect to happen.
3) more details!!!! We need to understand the problem. "it doesn't work" tells us nothing. Explain in detail what it does, what it doesn't do, why you expect different results, etc...

Remember,
A) we did not write the code - therefore we don't know what's supposed to happen
B) we cannot run your code - therefore we can't see what actually happened. Most of us are probably not going to create a project in our compiler just to execute your code.
C) so all we can do is look over your code. Therefore, if we don't know what we're looking for, it's very hard to find.

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

Convert the numbers to a string then concatenate.

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

This programs seems to run perfectly fine. but there is a bug in the get_number function I tried to find for hours but I couldnt.

The mind just boggles!

See if you guys can help me. Any help is greatly appreciated. Thanks

We could, but you didn't give us anything to work with. What makes you think there's a bug in a perfectly running program?

Details....

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

And your formatting makes the code very difficult to follow. Try a better fomrat and we can be much more helpful.

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

phani1092, what part of "First of all, we don't write programs for people, we help them write their own" did you not understand.

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

Did you fix if ((i = 10) && (userGuess != RANDOM_NUMBER)){ ??

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

It doesn't. You haven't address any of the problems I pointed you to.

As for your Access violation, k is probably an invalid value. Or guessValue is not part of the High or Low class.

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

The code you claim is the problem certainly has a major problem:

if ((i = 10) && (userGuess != RANDOM_NUMBER)){

This says:

set i to 10
is i true?  Yes, it's 10. It's ALWAYS true...

Did you want, perchance, to compare i with 10???? ;-)
Also, do you really want &&?
Finally, all you have is an IF that may output a message. This actually accomplishes nothing but output a message. Don't you want it to do more than that?

Think it through.

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

I'm still doing arrays starting from beginning to better get used it it.

Therefore speakon's code violate your major parameter -- using arrays.

phani1092 actually has the answer with "All you need to do is divide the program in two halves". The rest of his post though goes off track in a major way.

Programs should not mix processes. It makes them difficult to debug, and, as you have seen, difficult to write.

You have 3 defined processes:
1) input values
2) find max
3) output max

Separate your posted program into these 3 sections and the code you originally posted is very close.

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

Are you kidding me??!!??

Forst of all, we don't write programs for people, we help them write their own.

And the code:

#define ODD(X) (X%2)        // Why? This is just confusing when used

main(nargs, args)           // I haven't seen this MAIN signature since
int nargs;                  //    1985! AFAIK, this has been deprecated 
char **args;                //    for over 30 years
 {

    int *num = (int*)malloc(sizeof(int));   // Malloc one int? You're nuts!
    *num = 0;

    printf("enter number: ");
    if(!(scanf("%i", num) != -1) || (*num/10000 < 1 || *num/10000 > 10)) return 0xDEADBEEF;
                            // Unreadable worthless combination of multiple statements

    int values[MAX_SIZE];

    int*odd=(int*)malloc(sizeof(int)),*even=(int*)malloc(sizeof(int)),*zeroes=(int*)malloc(sizeof(int)),*remains=(int*)malloc(sizeof(int));
                            // Another unreadable mess, again mallocing single integers

That's enough...
Ian, don't bother with this code, there's nothing to learn from it. You can write your code far simpler than this.

Profyou gave helpful hints you can actually use.

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

Yes. fopen(). Your analysis of the problem is completely wrong. fopen() can open any file.

As AD said, "check the return value of fopen()". The fopen() probably failed for some reason.

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

I did not try it if it could have a bug or so

So code it and see how miserably it fails to do the job... 8-|

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

I'm reading directly from the disk, so I guess I have to use ReadFile();

Why? What does ReadFile() do that any other read technique doesn't do?

To alleviate your real problem, make your buffer larger than 512 -- say 16 more.
Always read into the last 512 of that buffer, leaving the first 16 bytes alone.
Just before reading the next 512 bytes, move the last 16 bytes into the first 16 bytes. You search on the entire 528 bytes.

char buf[528];

read into &buf[16];
compare
move buf[512-527] into buf[0 - 15]
read into &buf[16];
continue...
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@Rashakil Fol what the hell aare you talking about!! :O ??

Nothing. He's being an a$$.

happygeek commented: indeed +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Obviously not. Your last two posts were cryptic. You said the code is the answer -- meaning this is the correct solution. Then you ask if it's the correct solution. You already know the answer. It either works correctly or it doesn't. You never said one way or the other. What can we do if all you do is post riddles?

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

That's assuming a selection structure means a switch statement. Since we don't know the context of your terms, it's hard to say with accuracy.

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

for (i = srclen, j = 0; i < srclen && j < dstlen; i++, j++)

If i starts as srclen when will i < srclen be true? What happens to your loop in this case?

IMO, you need one more index value. Since you have srclen and dstlen you should have 1 more: resultlen

First Loop: resultlen starts at 0 and is incremented for each character added.
Second Loop: resultlen continues from where it left off...
Next: if you want a result string, where's the terminating \0 at the end of result?
Third loop: why use the complex printf() to output a single character when the simple function putchar() is created just for that purpose? Or if you actually make a result string, forget the loop and print the string itself.

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

Does it do what it's supposed to?

If so, it's probably good enough.
If not, tell us what the problems are. We can't help if we don't know what the problems are.

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

I don't see anything wrong with any line 18.

When asking for help, you need to give details. What is the problem you see? You gave us a line, but is it the same line in the post? If not, use the numbers in the post.