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

I just decided to call the post as it was... I guess it caught on.

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

No, you cannot use fread . The proper answer to gerard4143's question was "text", althought the proper question should have been "Is the file a binary or text file?"

Without knowing what actually happened using fget (whatever that is) we can't really tell what you did wrong.

Maybe you should try to explain the entire problem you are having since we aren't at your computer watching over your shoulder.

Details == understanding.
Vague phrases == guessing (and usually wrong, too)

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

If you are going 60 miles/hour, what is the miles/minute? What is the miles/second?

Can you answer these without a program? Just pen and paper?

If so, post the answers. If not, look up the equations and figure it out. This is the first step to programming the solution.

And what is spm? Seconds/minute? Seconds/mile? And when I said "tell us what the problem is" I meant start from teh top. What are you trying to do, what values did you expect, and what did you get. Details.

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

above programme is right,

but you have to maintain the indentation in the programme.

After you posted that unformatted code in another thread you have the gall to mention indentation here? Practice what you preach.

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

As the code stands, I see nothing wrong with it. It does exactly what you told it to -- tells you if each of two values are in the proper order, and which values.

If that's not what you want, you need to tell us more than "what's wrong with this code". You need to tell us what you wanted, what the code is doing, and what the code should have done. Details. Examples.

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

Sit down with pencil and paper and execute the code a line at a time. Watch what values come up. That's the best way to understand anything.

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

That seems reasonable, but what if the buffer is 20 characters and the user only enters 4 and hits enter?

What would the value of strlen() return in that case?

jonsca commented: Yup +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Oh yeah...I was going to say that, too. Don't use goto.

And, you can't actually control what the user will input. But your program can handle it if they do not enter what you want them to, if you add the code I suggested. :)

And he can fail the project for using code that was not taught and has no business using. The instructor will know that the code was given to him and he's getting others to write his code for him.

Please keep in mind who is asking and their level of knowledge before showing your prowess as a programmer and blowing their mind with higher level techniques. :icon_wink:

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

Excellent. You now know you have to read everything (including your book) carefully.

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

Please ignore yila's code. It is full of problems.

yila, please refrain from posting (supposedly) working code for people. They learn nothing so you are hurting more than helping. Especially when you use bad coding practices.

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

main()
{
    //declares an array of strings    
    string item_name[number_of_items];
    
    cout << "How many items does the customer have? \n";
    cin >> number_of_items;

When you use number_of_items, what value does it have? How large is the array?

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

Also, you did not start the program by defining a console program.

_tmain() and stdafx.h are not standard and supplied by VC because of the type of program you told it to create.

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

Bingo!!!!

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

Two things:
1) Title - Time interval....i need an answer pls.. -- i need an answer pls??? Why would you post a question and not expect an answer? Just describe the problem, don't add a useless order to it.
2) Always reread your post to make sure it is understandable. As written it makes no sense. Do you mean:

1) When you log in you have 30 minutes
a) before you can log out (stuck to 30 minutes logged in)
b) then you will be automatically logged out.

2) You cannot log back in for
a) 8 hours.
b) until the next day.

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

Look up the function strftime(). You can create any string you want with it.

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

@micjan : Congrats you got the code !!! I certainly wish the two smart people above get you everything you want in your life

Especially since both of them answered with terrible non-standard code, which makes the code dangerous to people's understanding of good code practices. Please ignore the code given.

Salem commented: They were horrid excuses for programs weren't they :) +19
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Because he's a weenie and thinks people want to use Java.

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

Well, I have multiple folders being created by different functions depending on what is selected from the menu. Would I be able to create differently named folders with the time function?

You can create any names you want. You are in complete control of the code and what each name contains.

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

Create the name using the time functions from ctime

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

Looking at your program, there are few things I haven't touched yet, like the goto statements but I get the general idea, so thanks.

Good. Stay away from the goto statement. It's considered bad programming and almost always an unnecessary command in C++.

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

Stop flooding the forums with new threads on this program. Use THIS thread only for your project.

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

but what should i change?

I don't know. It's your code. I guess I'd change:
1) anything that doesn't work
2) all that gotoxy() crap
3) your compiler. Update to a new compiler, not one that's been dead since the mid 1980's. But I assume it's your lame instructor making you learn stuff that's 25 years old rather than giving you proper tools.

If you ask an answerable question rather than a vague idea of a question, you can really get good help. But since we aren't writing your code, we can't really answer vague "what do I do now?" questions easily.

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

But what if there are SPACEs in the text box? How about using If trim(Text1.Text) = "" Then to be sure.

lloydi12345 commented: great! +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

LOL. wht can i say .. i just started c++ and made this prog today.!

Say you're sorry, don't do it again, and Read the Member Rules!!! Violating the rules will get you banned from the site.

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

I did the code tags...

jonsca commented: "with all the help about them, how could you miss using them????" -- Dr. Walter P Codetags (I'm thinking of starting a WaltP quote wall somewhere) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The statement a = a++; gives what is called undefined behavior because it is changing the variable a twice. Therefore the result may not be as expected.

Use either a = a+1; or a++; but not both.

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

Keep track of the number of days per year. If you need March 12, that would be 31+28+12 (Jan+Feb+Mar). Now you can use your 7 days to get the days of the week. The % (mod) operator can help here.

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

Eye found my kit on sail. How due ewe like it? Works good, does it knot?

Ezzaral commented: hehe +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Try it with 9.

You will find it is also even because in the loop when j=3, n%j = 0

This loop has nothing to do with odd/even. Where did you get this code?

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

Stop begging! Jeez! You sound like a whiny child in love with the letter Z.

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

If you have no clue how to accomplish this, you'd better start reading your book fast. Start with your include s

Ancient Dragon commented: right :) +26
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I wish there was an option in the "What are you posting" for tutorials hehe. But I guess I will just have to right it here :). If anyone else has any pointers (pun intended) let me know ;).

Ok if your like me and were wondering how to accept command line arguements I am going to show you how (I couldn't find any detailed enough to explain to me anyways).

How about this?

jonsca commented: But that's written by some dude named WaltP at that other site. You must have stolen his username (and avatar) for this site +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I suggest displaying all the values before and after you try the insert.
Display the array, used, current_index, and any other variables that will help you figure out the problem.

Run the code in the debugger is also a good idea.

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

You need to ask a question about what you don't understand. Not just post your assignment:
1) it looks like you want us to do it for you
2) we have no idea what you're having trouble with

When posting, details are more important than posting the assignment.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
  1. Use code tags.
  2. Is this a code snippet? You don't have it flagged as one.
  3. If not, what's the question?

Don't mention Code Snippet! They are posting enough Code Snippets already that we have to edit! :icon_twisted:

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

bantex, even though jephthah comes tromping into your thread being condescending and belligerent, spouting derisions and opinions with no backing explanations, he is correct. He feels you are just supposed to trust him. Allow me to add the small bits of information he neglected to tell you:

get rid of that "gets" statement right now. replace it with "fgets"

Yes, gets() is a very ill-behaved function. Here's why.

and change your "void main" to "int main(void)" while youre at it, since that is sloppy practice.

It's not sloppy. It's wrong. See this.

and, really, "conio.h"? "clrscr()"?? getch()???

conio.h is not standard C. It is an extension to a select few compilers and when you come to rely on it, you will find all your code broken when you change to a different compiler. Best to stick with standard C headers and functions.

your teacher needs to be hit upside the head with a board.

I also agree with him here, too. Your instructor needs to get out of the 1980's and teach real C -- Standard C, and stop using a 25-year-old compiler because it's familiar.

jephthah commented: i'll trade give you my green for your red. +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi, thank you all for your notes.

I've looked at the sites you've offered but dont seem to be able to make anything with them which suit my requirements.

They don't? What did the link tell you about feof() ?

You also never answered Q#2.

I may not have explained the problem that well, or perhaps C can't do whats needed as i've extensively looked across the net and not managed to find a function which does what i need.

Of course C can do what's needed. It's trivial. It's the programmer that needs to tell C to do it.

If you want help, you need to give proper information, not restate the obvious.
If you are having a problem, focus on the problem, not the end result.

What is the problem? Explain in detail. What happens that's wrong? What did you want to happen instead? Without that, we have no idea what you really need help with.

jonsca commented: "diff" must have been written in Pascal then ;) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

me too :confused:

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

Nathan's version: fout << v1[i] << "\n"; mrinal.s2008's version: *out_it = *p; Are they similar?
Do both forms work?

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

hi
Im trying to make this code go though every possible string combination at said string length though alpha characters using random number generator to do so.The goal is to make this program tell me how many combinations there are at said circumstances set by user.

Said problem is confusingly described by party of the first part in an attempt to impart wisdom as to salient description of said problem.

Do you mean "I want to figure out all the possible string combinations of a given set of characters?"

Are you in fact having a problem? I see no description of the difficulty you are having, just a task description.

And please format your code. When you need help from others, said others must be able to understand code posted. Formatting aids in said understanding.

NathanOliver commented: very nice +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hello everyone,

Background: I am currently attempting a project for a professor of mine, but I cannot integrate my formula properly into my code. The project calls for a conversion from numbers to words. (I last worked in C++ a year and a half ago, so any words that don't make sense in syntax are placeholders so I understand what I was trying to do when I have a chance to look up the proper functions later) I know how I want to isolate each number, and also how to have it export it. The problem I run into is with my IF statements when I am trying to extract the respective numbers.

Assuming the number I am searching for is 15824.23, I would first take off the .23 and deal with it at the end of the equation, and then turn the 15824 -> _15 824

I would take the 824, extract the 4 through mod then divide by 10 so it would truncate off the 4, mod by 10...rinse and repeat until I got each number. After I finished my first group of 3, I would move onto my next group of 3 until I ran out of numbers to extract basically.

<---code snipped--->

Any suggestions on how to best execute this would be appreciated, again I do not want the work done for me, I simply want some tips on the best ways to go about this.

Thanks,
CSStudent728

EDIT: I realize it is very incomplete …

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

Can someone help me with this code..
I have a function which is InsertNode()
it is use for inserting a new node after the index in the
double link list..

For example I want to add a node of value 6.0 after position 3
This is the code i write..but It seems like wrong...

What seems wrong about it? Is it just a feeling that it's wrong? If so, run it and find out if it is wrong.

If your feeling proves to be correct, then repost and explain what actually happened and what should have happened. Details are necessary.

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

A couple things to mention:
1.) This program uses system("PAUSE"); in the main function, if you are not using Windows, you might have to pull it.

Then you shouldn't use it at all. Keep your programs Standard so you don't have problems when you change compilers. See this.

HERE IS THE PROBLEM
I like to use (sizeof("Array To Be Used")/sizeof("Array Type")) to determine my Outer Loop limits.

Why? If you set up the array to be 5, use 5. Just make it a constant at the top of the program so that when you want to change the size you only need to do it in one place.

When I check the Arrays sizes right after I populate the data in main, everything is good. When I pass them to the function, they go down to 1 Element.

So when I am in the function findLowest and I try to get (sizeof(accidents)/sizeof(int)), it returns 1....

I'm wondering what I'm losing when I pass my int array through a function that only see's the array as one element (Although when I force it to show me each element it will, the sizeof( ) just isn't seeing the big picture....does that make sense?

You are losing the fact that there is an array. All the function knows is a pointer was passed in. It has no idea how many locations are associated with the pointer. You need to also pass the size into the function.

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

OK, I see the function.

If you want to return the player, why is it a void function? Let it return the player:

int getplayer(int thisplayer) 
{
    if (thisplayer == 0) 
    {
        thisplayer = 1;
    }
    else
    {
        thisplayer = 0;
    }
    return thisplayer;
}

Now you have either player 0 or player 1.

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

That's because each line you mentioned is extremely wrong.
Look up do-while loop to understand the syntax of the statement.

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

How can you not find information on CODE TAGS
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) any place CODE tags were used, even in responses to your posts
5) Even on the background of the box you actually typed your message in!

kvprajapati commented: nice reference for me, sir. +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

We need to send one to Graham Norton!

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

If pro is the opposite of con, what is the opposite of progress?

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

I have no idea why every post here is resurrecting an old thread with completely off topic questions, but it won't happen again...

Salem commented: Hell Yeah!!!!! +19