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

Create a vendor class, a customer class, an item class, and an order class.
Then decide on how they interact (which class connects to which class) and write the code that connects them.

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

Plz rd da rulz uv da forum, an da stickies at da top. Stop using baby talk, we are adults here. And we are not a free homework service.

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

You basically have to
1) create both months at the same time
or
2) use a 2d array and load the calendar into the array. When done, print the array.

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

Hi again,

After doing what you said, I bumped into another problem.

It's not nice to bump on a forum :D

You cannot create an array nor matrix using variables for its size.

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

I don't think it's appropriate to tell someone about hidden URLs. They are probably hidden for a reason. :icon_wink:

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

What is a CODE Tag?

:icon_rolleyes:
CODE TAGS are described:
1) in the Rules you were asked to read when you registered
2) in the text at the top of the C/C++ forums
3) in the announcement at the top of the C/C++ forums titled Please use BB Code and Inlinecode tags
4) in the sticky post in the C/C++ forums titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) on the background of the box you actually typed your message in on the C/C++ forums

How can you not know what they are?

And I am a little clear on the loop and wanted to make sure I had done it right.

If you're clear, that's good. If you're unclear you should ask in the proper forum. Not in the Feedback forum.

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

Green adds points to reputation.
Red subtracts.
Grey, no change to rep points. It's because the person that gives rep doesn't have enough posts that actually affect someone's rep.

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

First question:
Is this equation really supposed to return a julian date? julianDay = day1 + (153 * m + 2) / 5 + y * 365 + y / 4 - y/100 + y/400 - 32045; It might help if getDayNumber() returns the value calculated.

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

Split the number into individual digits and place the digits into an array. Then loop thru the array from the last value.

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

Now that's an appropriate question. You:
1) state what you want to accomplish
2) show what you're starting with
3) show the output
4) Then show your solutions
You get points off for not using CODE Tags though.

Now, if you are asking if the loops produce the correct output, wouldn't it be faster to just run them? Other option is that you want comments on the two loops to see if you missed something or can improve them.

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

1: Zero your Total
2: Read the input as a string (hex)
3: Check each character and conve rt it into decimal value (A=10, B=11, etc)
4: Multiply Total by 16 and add the above value
5: Back to 2

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

I do not even know what question to ask............

Then expect an appropriate answer. Only a couple of us are psychic...

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

Sorry, Xlphos. After all the posts that can't get the correct word, that one more pushed me over the edge. I'm OK now.


By the way, it's grammar :icon_wink:

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

Oh. I get ya... :)

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

I'm considering allocating the space on behalf of the caller as a bad practice (except malloc in C, but no need in malloc in C++ ):
1. It's annoying and error-prone to deallocate returned memory on behalf of the callee. It's a narrow pedantry to count this tiny buffer size in relatively expensive (operator divide) loop. As usually, there is some minimal size of an allocated heap chunk in C++ implementations (16 bytes or ever more) so you can't save actual memory expenses.

Exactly! What I said about malloc() in my first post goes for new too. STOP USING IT! Reread what I said.

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

dose it making the beep from the motherboard speaker or from you desktop speakers, if you can mute the mothereboard speaker

Can't tell. Not sure if there is a motherboard speaker.

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

Hi I have just been looking at the tutorial section and noticed their is very little there.

[RANT] What is it about there/their/they're that no one seems to know that the words are not interchangeable! Are the definitions that ambiguous? [/RANT] :icon_rolleyes:

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

press ctrl-f in one of your threads and type: Mark as Solved. It will show you link that is just above the (purple in this case) "quick reply to thread" bar.

Ctrl-F brings up the FIND dialog in FFox and IE. At least for me...

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

Yes it is a good place. But if, as you say, "when someone has NO IDEA where to begin or what to do" this is not the place to get started. Their instructor is the one to ask. Once they have some code that looks like they at least tried to start, we can help.

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

isnt gets() almost the same as scanf()? im using it because it gets more characters than scanf().

Yes. See this and this. Stop using gets() !

C code works inside C++ right. we use C++ in class and i dont think thats a problem, for me.

Then write C++ instead of C. If you want to write C code you must follow the rules of C and stop arguing with those that know the rules.

aiight, dude. i'm tired of all this grabassery. here's standard c, that will actually work.

He finally got to you... Oh well. :icon_wink:

Salem commented: Saying "Noooooooo" to gets() :) +29
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Somehow I don't think this compiles.

In my compiler:

Error E2268 x.cpp 15: Call to undefined function 'count_file_values' in function main()
Error E2313 x.cpp 16: Constant expression required in function main()
Error E2451 x.cpp 18: Undefined symbol 'cout' in function main()
Error E2268 x.cpp 22: Call to undefined function 'display_array' in function main()
Error E2451 x.cpp 30: Undefined symbol 'fstream' in function count_file_values(char *)
Error E2379 x.cpp 30: Statement missing ; in function count_file_values(char *)
Error E2451 x.cpp 34: Undefined symbol 'inData' in function count_file_values(char *)
Error E2090 x.cpp 34: Qualifier 'ios' is not a class or namespace name in function count_file_values(char *)
Error E2121 x.cpp 34: Function call missing ) in function count_file_values(char *)
Error E2451 x.cpp 37: Undefined symbol 'cout' in function count_file_values(char *)
Error E2268 x.cpp 39: Call to undefined function 'exit' in function count_file_values(char *)
Error E2451 x.cpp 39: Undefined symbol 'EXIT_FAILURE' in function count_file_values(char *)
Warning W8057 x.cpp 52: Parameter 'input_filename' is never used in function count_file_values(char *)
Error E2451 x.cpp 56: Undefined symbol 'fstream' in function load_file(char *,int *,int)
Error E2379 x.cpp 56: Statement missing ; in function load_file(char *,int *,int)
Error E2451 x.cpp 58: Undefined symbol 'inData' in function load_file(char *,int *,int)
Error E2090 x.cpp 58: Qualifier 'ios' is not a class or namespace name in function load_file(char *,int *,int)
Error E2121 x.cpp 58: Function call missing ) in function load_file(char *,int *,int)
Error E2451 x.cpp 61: Undefined symbol 'cout' in function load_file(char *,int *,int)
Error E2451 x.cpp 63: Undefined symbol …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Did you somehow fail to read all of the information posted all over this site about CODE tags, like
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) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) even on the background of the box you actually typed your message in

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

Hello everyone, I'm working on a small assignment where I am supposed to write the code for the itoa function char* itoa(int Value, int Base); without using any built-in functions, and where the returned value is allocated on behalf of the caller. Value being the integer to convert, and base being octal, decimal, or hex.

I found this rather simple implementation and I was hoping we could discuss it here to see if the changes I'm making are appropriate/accurate and etc.

OK, have a seat...
1) malloc() -- this will cause memory leaks on each call. Once the function returns, the memory address allocated is lost and can not be returned to the heap. Stick with the static char from the original code.

2)

for(int i=30; val && i; --i)
  {
    val /= base;
    buf[i] = "0123456789abcdef"[val % base];
  }

The first thing you do in the loop is remove the low order digit so if you pass in 2765 you would get back 276.

3)

buf[i] = "0123456789abcdef"[val % base];

This is a trick that I personally would avoid -- but that's just me. Create a char* with the character values.
Also, what happens if the base passed in is > 16? This line will cause a lot of trouble. You need to test for proper base range to protect the program this function is used it.

tux4life commented: Nice posting, nice advices to the OP :) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

do you try another button to get into the B.I.O.S ?
What kind of type your laptop?

Such as?
It's a Phoenix Bios.

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

Regrettably, there is no a little thing in <ctime>: guarantee of 32-bit integer time type.
The time_t type is an arithmetic type capable of representing times - that's all...

I don't understand... Is there a problem with ctime?

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

Did you bother to read any of the requested information posted all over this site about CODE tags, like
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) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used
6) on the background of the box you actually typed your message in

Salem commented: Indeed, well said +29
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK, fine. It's generally the last thing a professional programmer would do.

Peeking is generally used for OS level programming when you need to do things outside the ordinary. Reading the character and processing it is ordinary. And this task certainly can be done easily using the ordinary techniques.

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

Here's a guy that was living on that forum

RSS
# Total Posts: 3,444
# Posts Per Day: 127.73
* Last Activity: 03-26-2009 03:03 PM
* Join Date: 03-26-2009
* Referrals: 0

Looks like their bookkeeping needs some updating...

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

Yeah, he should be severely dealt with!

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

My ghod! Don't use cin.peek()! Read the line as text and process it.

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

Look at the header ctime. All the time functions are there. A Google search should give you definitions and explanations.

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

Iterations is the number of times to do the calculation. You use it correctly in your code:

cout <<" On how many iterations? ";
cin >>i;
for (long int n = 1; n <= i; n++)
{
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I have 2 functions: one has to calculate the total number of days spent on a trip and the other has to calcualte the time of departure on the first day of the trip and the arrival back home on the last day of the trip.

OK, so far

In the first function, don you calculate the total number of days just by cin and return to that function?

Don know. We have no information on the design specs of the program. You certainly could do it using cin.

Im totally lost on how to calculate the time of departure on the first day....i'm thinking that there is some type of pre-processor directive for the date and time but I cant think of it...can anyone offer any suggestions?

We have no idea how your 'time' is stored. If it's in seconds, you do one thing. If it's in 'time format' you do something else.

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

My laptop did that and the setting to disable volume beep was in the BIOS.

Check your BIOS.

Thanks, JB. Never thought of that...
Unfortunately, my bios only sets time and boot order. There is nothing else settable in it.

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

No. Your loop reads each letter, overwriting the previous character. When the loop ends all you have is the 5th character entered

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

For some reason on my new laptop I can't seem to turn off that annoying BEEP when I change the speaker volume. I got everything else turned off but this beep seems to be bypassing the "Sounds and Audio Devices" properties.

Any ideas?

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

Oh. Interesting. I grok the joke now... :)

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

Well, I never thought it is a homework. The OP never mentioned. He told it is some kind of his project.

I've been here long enough to tell.

Also, if they are having a course on C++, the instructor is expected to teach the language rather than programming. These are off course two different things.

Not in my world. Instructors teach programming and use the language as a tool. At least they did in my day. Maybe they don't today -- which is why there are so few real programmers today, eh? Just coders who can't figure out why things work... :icon_wink:

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

What integer is '|'? That looks like a character so you cannot read it into an int variable.

To do what you need you'll have to read the input as characters. If you get a number, convert it to an integer. If it's not a number, do what you need with the character.

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

This is what I always say: Use the standard library for the standard jobs.
If I assume you are familiar with std::vectors, std::maps, std::sort, there is no reason not to use them.

And this is what I say -- if you look at the code posted it quite obvious that std::vectors, std::maps, std::sort are not in their toolkit yet. And using these things nullify the learning process on how these things work -- the instructor is obviously trying to teach them to understand techniques. When you get into another language, all the STL knowledge is totally useless. You need to actually know things.

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

Start by changing each line in the pseudo code into real code. Use the correct syntax for each command you use. Then add code before this conversion to add the things needed to make it compile -- like variable/array definitions, main(), header files, etc.

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

u should have to use cin instead of cin.get because cin.get mostly used in case of string
use cin as below


char choice[5];
cout<<"ENTER YOUR CHOICE"<<endl;
choice=getche;
switch(choice)
case '1':
sum=a+B;
break;
case '2':
multi=a*b;
//up to 5 choices and then default choice

I'm at a loss. You say "u should have to use cin" and post code that doesn't use cin . What are you trying to do, confuse people? :icon_wink:

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

My previous post says -- post your new code!

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

This is a perfectly legitimate question for this forum. It's about reading special key sequences. The hardware is just a red herring in this case :icon_wink:


1B 5B 41 is called an escape sequence. In this case ESC [A . So...

When you read a 1B set a flag that remembers that an ESC sequence is being read.
Read the next char, verify it's 5B and forget it.
Read the next char, use a special switch statement for ESC sequences only which processes the arrow and whatever other sequences you deem necessary, and clear your flag.

jephthah commented: thanks for correcting +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Are you saying you have been giving incorrect solutions all this time?

No. She doesn't give solutions. She gives help... with a side dish of attitude :)

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

Argyou? Really?

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

Why doesn't it compile? Don't you have a compiler? If you do, did you get errors? If you did, are we supposed to guess what they are?

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

You need to define some arrays first. Then we might be able to help you.

You also need to format your code so we can follow the code. Don't instructors teach proper formatting techniques these days?

tux4life commented: You've got a point here :) +3
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

hey its generating 50 numbers in first file(file1).but in file 2 its reading the same first line again in file2.

Hey, that's too bad. My psychic powers are on the fritz today so I can't see the changes you made with my mind's eye. You'll just have to use another method of getting the current code to us...