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

You should avoid goto completely. After 30 years in C, I've never needed one.

Restructure your program to use one of the 3 loop structures.

As for why it executes twice, when you type your answer, how many keys do you actually press? What do you think is now happening?

[edit]
One more thing:
Why use an expensive function like scanf() to read a single character? getchar() is specifically designed to read a character without all the overhead.

It won't solve your double-execute problem, though...
[/edit]

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

A couple other things worth noting:

1: do{}while((c = fgetc(input)) != '\n');
Why a do-while? Why not just while((c = fgetc(input)) != '\n');??

2: fseek(input, -1, SEEK_CUR);
Why? Can't you do something better/cleaner than messing with the file pointer?
It looks like you're already handling the case without the fseek().

3: printf("%c", c);
This is a very expensive statement to use for character output. It's much cleaner to use putchar().

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

Also printf() is a very expensive way to output a single character. Better to use putchar('*') because it's made specifically to output a single character.

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

cin.get(); is not working for me to pause the console window.

Then your basic input concepts are leaving the input buffer dirty. Change your cin>>timinput to a getline().

So if I have "08:30" as timein, and "17:30" as timeout the result of difftime() must be 9.5. timediff=difftime(timeout,timein)..

How do you get 9.5? That looks wrong to me.

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

Did you display the values in your tm structures to verify the data is correct? If it isn't, there's no sense comverting anything.

Also, please format your code so it can be read and understood easier. When you get into more complex programs this will be a major help to you. Also, stop using system("pause"). Here's why

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

Do you know how to work with structures yet?
If so, it's no different from what you already know.
If not, you might want to wait until you get to the chapter on structures before tackling this program.

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

Of course.

Parse the string into it's components (a 17 and a 30).
Fill a time structure (defined in time.h) with the appropriate values.
Call the appropriate time function in to convert the structure into time_t.

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

I havent tested the above code?

Why not? How do you know what needs to change if you haven't bothered to try it?

Any correction?

Too much to go into. Based on what you've posted you need to go way back to the basics. Like
1) the infamous Hello World program for basic program layout
2) basic input into integer variables
3) basic comparison (if) statements
4) not understanding what time_t variables are

Did you do a search for info at all?

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

Yes it is. Your solution is leaning toward code you can find at this site. Most is quite precise, but.... ;o)

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

Anybody knows where the problem is?

It's on (or near) the line mentioned in the error. Unfortunately, when you don't tell us the line, or indicate the line because the post numbering is different than your code numbering, it kinda hard to pinpoint the where. Please remember to post all pertinant information necessary to help us help you.

Now in this case, I see a major faux pas. On the line
if (strcmp(static_cast<char>(line.getline(PlayerID,2,'\n')),respcode)!=0)
(which I suppose is your error line) why are you
1) reading data
2) calling a function
3) casting data
4) testing data
all in one line? Split it up into multiple appropriate statements so you can see exactly what you are doing. This often helps in understanding not only the code but any problems that arise.

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

And yet another "not totally working" post, as if we're supposed to know what that means. When asking for help, give us information. Don't make us guess what "not working" means.

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

For those interested here it is. Now how do you delete posts?

If the post was deleted, why would we be interested? ;o)

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

Unfortunately, we can't see your screen to see what the errors and warnings are.

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

Yes, it's precision, and double is simply more accurate. That does not equate to bigger.

For example: double may be 56.42735816, float may be 56.42736 -- float is bigger.

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

Then, as deceptikon says, it's not supported by that compiler. Write your own.

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

And Labdabeta, what do you mean by arbitrary arithmetic library ?

Bad choice of words. He means a large-number arithmetic library? Arbitrary is not correct. You want to pick a package with care.

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

You can just use the top navigation menu dropdown links

Sure. But I have to do a lot of scrolling which I don't find user friendly.

As for

many people complained that the "favorite" forums it showed weren't where they wanted to go usually

what about us that liked it and, because it wasn't a complaint, didn't rave about it? I remember commenting on it favorably.

And for those that can't use it because of the above, they don't have to use it. Just like no one has to use TAGs, but they are there for the few that do.

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

Hope it helps :)

Probably not, since this was already suggested and rejected.

You should read the entire thread before posting.

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

Maybe

x = rand() %2;
if (x == 0) x = 1;
    else    x = 3;
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Unfortunately, the one entry on the bar I used to use is missing -- The Favorite Forum links.

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

What does "not working" mean? Details.

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

Is i0 and i1 variable names? If they are that means I have to have to counters for zero[] and one[].

Of course.

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

This usually means object is just a pointer -- there's no storage space.

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

Where you call print() you can break out of the loop.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
a[r[i]] = zero[i0++];
a[r[i]] = one [i1++];

Also, at least consider what NathanOliver said.

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

Any tips on how to solve this?

Not without a better description. There is no explanation what r contains.
You didn't tell us but a seems to contain your 4 random numbers.
The indexes into zero and one -- are those just guesses? It there any reason those numbers were chosen?

You really need to explain fully before anyone can really attempt to offer advice.

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

here is the insert function I will consider your notes but what is the problem with my code??

You tell us what the problem is. Reading code is hard enough without searching for some unknown error.

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

That's what happens when someone over-explains something when in fact a previous post answered the question...

If

The issue is as identified by Lerner

why the long disertation that only confused the poster?

Also:

the stuff with the constructors isn't too difficult.

It is when

I have only had one class in C++ and have done some minor learning outside of it.

When someone is struggling with one thing, heaping more on them is just more confusion. A step at a time.

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

It seems to me that the error "no instance of overloaded function" means you have not defined the proper namespace at the beginning of the program. This could cause the 3-parameter getline() to be unknown.

Also, see this about reading and looping (feof() is identical to your (.eofbit`)

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

abc was never set to NULL. It contains junk since all you did was define it.

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

yes, you'll get same value if you use double.

I really wish people would learn the details before regurgitating bad information all over these forums.

No, double will not correct the problem. Float and double both have the same inexactness problem, just at different levels. It cannot be solved. It simply has to be understood and dealt with.

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

Can you not just take some code, then go onto different forums (Java, C++) etc.. and ask what the code is,

You shouldn't. You should post in a more generic forum (Computer Science) so you post only once. Also, since you don't know what language it is, posting Perl code in the C++ or Java forum is frowned upon -- therefore Computer Science.

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

why root is not NULL? or how can i make it to NULL?

Why do you want it to be NULL? You just malloced some memory and put the address of it into root. Do you really want to loose that memory causing a memory leek?

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

1.warning at line 16 return type of main is not int

Take one guess.

2.error at line 18 syntax before "printf"

Look at the line before printf. What's missing?

ok waltp why cant we nest structures????

Ask the people that designed the language. I never cared why. They said you can't so I don't.

And do what deceptikon suggests. Answering all these basic questions gets tiresome when all you have to do is study the material in your book.

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

Copy and paste the errors, don't post a screenshot.

Explain the problem -- don't make us try to figure it out.

You cannot nest structures.

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

Arrays maybe?

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

Try printing out avarything you read in as soon as you read it.
Can you use STRINGs rather than CHARs? If not, make your CHAR array larger -- say [20].

...oh my,

Channelling George Takai, I see... ;-)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
i++,++j;
k = i>j? i: j;

That's not your macro. The macro is only 1 line.
Try it again.

Study the definition of a magro again.

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

Try it and find out! You'll get the answer in seconds!

I fear for the future

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

Why should it be?

Remove MAX and put the macro code directly in your code and see what happens.

Post the results.

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

I still don't see a question. All we can do with the info you gave us is write it for you. That's not how we work here. What problems are you having? What have you tried? What don't you understand?

And, just so you know, your professor is 30 years out of touch with programming. He's forcing you to use the equivalent of spears when the rest of the world uses lasers. He's teaching you something you'll never use in the real world.

i just need a super simple and basic codes :) thanks

Ahh, I see. You do want us to write it for you. Sorry, not going to happen. We don't get the grade and you won't deserve it. And what would your professor say when he finds out?

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

Yes, we can help. Ask a question...

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

How do you "generate four random numbers from the array"?
refer to first post

Telling me to re-read the post I quoted does NOT answer the question. I'm asking because your first post says this and I don't understand it.

what's in the array?
random numbers

So it's just crap in the array from uninitialize data and you have no idea what the values are. Got it.

What about the 7x4 array?

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

Given a 7x4 array generate four random numbers from the array with no repetition.

Your code and your description don't match at all. Where is your 7x4 array?
How do you "generate four random numbers from the array"? what's in the array?

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

Completely disagree. After only 1 week, you don't have the background in the language to even think about graphics yet. Learn the language first. Graphics can come later.

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

No, design, as in plan.

If you are going to make a car, do you just throw metal together and hope it works? No, you design the car. When the design is finished, you then build the car based on the design. Same with a program.

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

It's difficult. You have to understand how to design, store, and retrieve data from a database you design.

I'd go with something like craps, tic-tac-toe, mastermind (also somewhat complex). A game that remembers a little bit of information but not too much.

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.