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

Compare the string with "source:" using strncmp() then use strcpy() using the form &buf[7] to point after source:

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

Thank -- not sure why you are being snotty for I think that for a first time Linked Lister, I am not doing too bad of a job.

Joe wasn't being snotty, he gave you the suggestions you needed, all 3 of them. And we have no idea what this means:

I copied the first part of the problem's program, but it is coming out different.

In what way? When you copy and paste you should get exactly what you copied.

And I'm going to add one new request -- you need to format your code. As it is, your code is difficult to follow without indentation. To get the best help, make your code easier to read.

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

Hello eveyone,

I am working on a program that uses the graphics.h library functions
and the 0x33 mouse interrupt. When I click at a particular place on the
screen, the graphics nearby the mouse are saved and displayed on the
new screen (that appears due to the mouse click) when the mouse
position is changed. The same happens when I drag the mouse from one point to another.

Can some-one suggest a possible solution ?

Solution to what? You described what happens, but not what is wrong with what happens, nor what you actually want to happen.

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

Assume that x becomes whatever value the problem says is input. Then, line by line figure out what each line is doing and fill in the number 'input' for x.
What if anything is output?

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

Read this series on scanf() , esp the character post. It will explain what happened.

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

You have to know what F1 actually is when you press it, and code for that. As it is, I don't see anywhere you actually defined the value you expect for the key.

And since getch() returns an int, and in the function you cast everything to ints anyway, why not just define opc as an int?

And never give two different functions the same name -- even if one is menu and the other MENU .

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

I would have love for you to finished the sentence. :)

I did. That was the end of the sentence. Whole thing was: "doesn't do what you think the code does either, which is sort..."

jobellelaiza, your code

float detect(floating point1,floating point2,floating point3)
  {
    float small;
    if (floating point1 < floating point2 && floating point1 < floating point3)
      smallest = floating point1;
    if (floating pont2 < floating point1 && floating point2 < floating point3)
      smallest = floating point2;
    if (floating point3 < floating point1 && floating point3 < floating point2)
      smallest = floating point3;
    return (smallest);
   }

is just too complex. Simply set the min to floating_point1. Then a single IF to test small with floating_point2. Then a one more IF to test small with floating_point3. And done... But make the variables match and try compiling more often. It's impossible to get code to run correctly when it just won't compile.

For #2, enter all your integers into your array in one loop. Then look for the smallest in another loop. It's usually best to do each task separately rather than mix them all together. It's easier to write, and debug.

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

@ WALP,

Thx for ur suggestion.....but the code that I typed seems to be already formatted above in a better way...

It does? Try actually reading the link I posted and look at your 'readable' code...

dont no who did that but is that readable now??

SOS did it, and no it's not readable.

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

>Plz answer my these C doubts-
"Doubt" is sometimes synonymous with "question", but not in this case. It's very common to ignorantly use doubt in place of question, and it's usually wrong. What you have a C questions, not C doubts.

I think this is something taught in India. The only posters that have 'doubts' seem to be from there...

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

Hi,

I need some input on an assignment I am doing. I am not sure if I even did this assignment right or not. So any help would be appreciated.

OK. Input is:
Start writing the program.
Write the input module and test it.
Write the output module and test it.
Add the conversion module for one currency and test it.
Add the other conversions and test it.

Be sure to post code in CODE tags when you need help on what you've written.

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

Nice try -- doesn't even remotely do what jobellelaiza needs, and doesn't do what you think the code does either, which is sort...

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

Hmm something removed all my tabulation which made code soooo much easier to read.
Anyone know how to keep tabs in code blocks for legibility?

Change your TABs to SPACEs. There is probably a setting in your IDE options.

As for system("pause");, see this. Put your cin.get() in a loop and watch for the ENTER (\n).

The format for an IF-ELSE statement is:

if (comparison)
{
    code if true
}
else
{
    code if false
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

:twisted:
a a
n n
n d
o
u g
n o
c o
e g
m l
e e
n
t
s
:p

WolfPack commented: Nice - WoLfPaCk +5
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do you know what a loop is? Both programs require at least one loop and an IF statement.

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

2 things, please
#1) Format your code. We'd like to be able to read it and help you.
#2) English, please. This is a professional programming board, not a chat room.

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

Google for RPG II.

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

Sir I appreciate your suggestions but I'm really a noob with regards to C such that i don't know how to implement it. Could you give me any sample/hint. Sorry for being very slow with this part. Hope you could understand.

Follow Dave's suggestion at your GID post. With all the help you've been given so far here and there you should have this program done. Or are you getting confused because the two threads are telling you to do different things?

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

... keeping an eye on the porn... bloggers - but I do that anyway.)

Hmmmm so that's what you do... :mrgreen:

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

hi,

Hi.

i want to develop a console interface for a program that i made{a university project}......

so i was wondering if anyone {with expertise in this matter} can supply me with links or examples.....

For example , i am searching for ascii art...and also for ways to create menus with back and forth options, clear screen, use colors.....etc made it look more professional than a simple menu....

There are some old compilers that can do some of this, but the techniques won't work with new compilers. What are your options for compilers?

sorry i am not more specific,

Don't be sorry. Be more specific ;)

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

i got try to move to virtual C++ compiler, but my codding all become not match on it, because it is build up using borland compiler.

as a conclusion here, the program code that build up by different compiler canot be run although based on theory, the codding is C++ coding.

What are you using that's only available on Borland? I see nothing in what you posted that's Borland specific, so it should compile on any compiler.

If something doesn't work, you have to tell us why and how it failed and the code you used.

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

OK, since you are new, allow me to correct things in your program first before tackling the coding of the problem. By the way, what's an erm? ;)

Problem#1: Format your code! You need to learn to indent your code properly so it can be followed, and it's better to learn it now than unlearn a bad habit later. This includes spacing: for(i=0;s!='\0';i++) vs for (i = 0; s != '\0'; i++) Problem#2: gets() -- just stop using it. Period. Forget it exists!

Problem#3: system ("pause"); -- see #2

limitaitons
- will give wrong output for a statement with more than one space between words
- wrong output for leading and trailing spaces

That's because all you are doing is counting spaces, not words. You need to decide what represents a word. Each time you see the beginning of a word, add one to the word count and set a flag that indicates you are in a word. Each time you see the ending of a word, set that same flag to indicate you are not in a word. A simple flag = 0; and flag = 1; (false=0 and true=1) would work fine for the flag. Now you have to figure out what constitutes the beginning and end of a word.

Since you already understand that characters are just values (very good for a new programmer!) you can simply set up your h array to be 127 instead …

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

check this:

while ((first < second || third != fourth) && iteration < 5);

Finish parenthesizing for readability...

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

too much for

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

seen as friendly

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

Let's fully parenthesize the comparison, shall we? No sense going half way and this remove all ambiguity:

// will be executed atleast once
do
{
    // something
}
while (((first < second) && (third != fourth)) || (iterations < 5)) ;
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The story so far...


It was late on a very dark January night...

when Caroline arrived home from work.

The wind touched down upon the shingles of the house while the gaslights fluttered in a copper haze.

"Is that you, Caroline?" her husband called from his study.

Caroline paused, worried at this sudden, unexpected kindness. He only ever did this when he'd done something he knew she'd hate. It wasn't a good omen.

'What has he done now?' she thought to herself, going back to times past when he had been caught having an affair with his young secretary Jenna

"Come in here, quickly" he called. Apprehensively, she walked to the open study door and took a deep breath before entering.

"Here, I've poured us both a Brandy", he said, "we're going to need it". Caroline was shocked! Her husband, Sherman, had been sober for nearly three years.

"I'll get straight to the point," Sherman quavered, spilling a little brandy on the coffee table. "I went down into the toolshed yesterday. There was...a baby there."

'A baby!!!' Caroline excalimed. How on earth did that get there I wonder??

"I don't know, but at least she is alive and healthy. Nicolas is caring for her now. Thank God I found her when I did.", Sherman sighed, then added reluctantly, "I have to tell you something, Caroline. The aspen trees in the witch's grove have been charred again."

…

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

Unbeknownst to Caroline, Azrothic entered the village. "I'm close," she muttered, "I can smell the little beast." And unrevealed to Azrothic, Caroline (as Smakta) was much more powerful than than even her. The fight should be swift, and will not go well unless she finds help.

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

, but today it's

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

strengthen your stamina

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

puptent

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

Fine, go to the party -- just be back by midnight!!!

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

Mainly Dew.
Occasional Coke/Pepsi.
Never coffee. I cant stand it.

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

Smart@sses have all the good answers!!

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

also in relation to post #45

telly = custard and jelly

I heard of that slang style. I've never quite understood how specific phrases become 'universal' though. It seems so ambiguous... They're quite interesting, though.

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

what is puce?

Check the OED :D

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

I know, I know :)

It was an attempt at humour/humor/being funny...

Me too! That's why Mr Green made an appearance ;) I like Mr. Green.... Can we get one that's puce -- it's such a funny name for a color... :twisted:

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

It doesn't, but the smallest prime number is 2, so the largest prime number for n is n/2. Anything >n/2 and <n cannot be a factor of n, so why check above n/2

thnx. but wat beats me is .. what is the need for n/2 ?

why do we need to consider half of the no. to check if its a prime ?:-|

Sheesh! OK, you want to find out if 31 is prime. What's half of 31? 15, rounded down. The next value is 16. Can 16 possibly be a factor of 31? How about 17, 18, 19...? If it's impossible, why check them? Therefore you can stop checking at n/2

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

So I take it the only reason for you responding to this thread was to increase your post count? I'm looking for a tutorial for code caving because I receive multiple requests on my website; however I do not have time to write one. I was hoping by going out of my way and find a published tutorial to link to would suffice.

I would have suspected (must be due to ignorance) a moderator of this board would be more keen on helping someone, not flex his ego.

Considering only his post count, I would say JWenting is a more honoured member at 100 times your post count. Add to that you haven't been here for 1.5 years, you have no reason to snipe a one of our senior members simply because you feel his response was of no help to you. I for one felt it was justified as I found answers on my first Google attempt. Based on your response here, you have nothing to complain about...

Keep it respectful. Infractions are easy to receive.

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

Hi there, I'm just getting back into c++ after a 2 year break.

You are also hijacking a thread by someone else. Start a new thread with your question, and use CODE tags, not INLINECODE tags for a block of code.

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

why does 'y' need to be < x/2 ??:-|

It doesn't, but the smallest prime number is 2, so the largest prime number for n is n/2. Anything >n/2 and <n cannot be a factor of n, so why check above n/2

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

Look into the strstr() function.

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

Read this and this

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

What strain of English is c'mon :)

It's a much-used contraction, as Joe mentions. It's informal. So there :mrgreen: At least is was used correctly...

So what does your OED say about the use of there to mean "a form of the possessive case of they used as an attributive adjective" or "contraction of they are"?

But then who am I to argue with a writer :D

A user of the language. ;)

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

And this is just my opinion, but: I don't really see why using numbers in place of characters makes the code any clearer.

Yeah.... well it is a good thing it is your opinion. :lol:

Well, it's not just your opinion, Joe. I am in complete agreement that
if ((str[i] >= 'a' && str[i] <= 'z'))
is extremely more readable than
if ((str[i] >= 65 && str[i] <= 90))
And it will even work for code on EBCDIC machines... :p

I'd like to hear any dissenting opinion that is sensible...

John A commented: Well, that's good to know, thank you. --joeprogrammer +8
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

can u gv an example of the way u said juz now? thanks....
and also the error juz now i state at the 1st post... thanks

ok.... 10s.. i will try to read it out 1st...

hm... look like the way u write is different from wat i write........ so i need more time to understand it..........

did u understand the 2nd code that i post up juz now?

OK, it's now time for you to read the Rules. You should read them all, but this first paragraph is important...

Salem commented: random rep++ from salem +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i cant paste all the coding here cause it is too long and involve many different CPP file,

So post just the code section you are asking about. With details about what is going on and how the variables are defined, we can usually read code segments easier than 100s of lines of code anyway...

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

Not even going to try to read this code. Format it and repost, and use CODE tags.

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

As I said, you do not want to display the message in searchPlayer . Since you basically have it, I'll give this one to you:

bool playerType::searchPlayer(string searchFirst, string searchLast)
{
    bool found = false;
    if ((getFirstName() == searchFirst) && (getLastName() == searchLast))
    {
        found = true;
    }
    return found;
}
int  n;
    cout << "Enter the ... ";
    cin >> fname >> lname;
    for (n = 0; n < 6; n++)
    {
        if (player[n].searchPlayer(fname, lname))
        {
            cout << "Player " << n << " is ";
            cout << fname << ' ' << lname << endl;
        }
    }
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The statement is not absolute as such. It all depends on the problem under consideration.

Which is why I stated it as I did -- not as an absolute. ;)

That's more a matter of style for ease of maintenance, AFAICT. IMHO, this function is more clear this way, though if you want a single return, it could be done as

int max(int a, int b) {
  return (a > b ? a : b);
}

but I didn't want to post that one for clarity's sake.

Very good choice!!

Purists frown on multiple returns. They can be harder to debug because sometimes a return gets lost in complex or long functions. IMO, you should try to use only one return point if the code to support it does not make the code overly complex. But don't make the code difficult to read to accomplish it.

For this piece of code I'd probably use:

int max(int a, int b)
{
    int rtn = a;
    if(a < b)  rtn = b;
    return rtn;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

c'mon, please use English! Especially those that claim English is their first language

there -- like "over there", location
they're -- short for "they are"
their -- they own it, "it's their book"

Sorry, but this really bugs me..... :confused: