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

void digits(int n); is not a function call. It's a definition. Get rid of ALL the types an just use digits(n); , as all your examples should have shown...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
void digits(int)
{
int n

cout << "You entered the number" << n;
return;
}

So what is your parameter variable? All I see is a parameter type, not a variable.

And since your examples don't use a parameter, keep looking at more examples -- preferably one that has a parameter.

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

You've been told twice that your digits() needs a parameter. jonsca even provided you with the format of a function. Now, go back to your book, look at the section on functions and read it. Look at the examples. Then try to make digits() look like those examples.

If it still doesn't work, post a very detailed explanation of what you tried and what happened. Your explanation:

when i place int there i run into the problem where it either error you get set a int to a character or too few arguments and any of my ideas to make an if else statment in my funtion to compare the int to

is not helpful to us.

Also, note that your instructions say:

The function should not return a value

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

Walt please help how to apply your solution with the full C source code.
Please modify my C source code.

You want me to write the full C source code for you? I can send you a contract and you can hire me as your personal programmer. I'll give you the student rate of $50 and hour, minimum 10 hours.

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

Please send me a copy of the book by the fastest route possible. Then I can look at the problem, laugh at how simple it is, then wonder if someone else helped you cheat while I waited.

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

I'm not sure I understand how do you know it was another pc. What would another pc have to to with it? C++ is C++ and shouldn't change from pc to pc. Just because it seems to work doesn't mean it's correct. Many errors can hide in bad code. Remember the pentium problem with floating point numbers from years ago? Look it up.

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

Actually, there are three, but one is commented out ;o)

:icon_rolleyes: Then the commented out getline() must be the culprit...

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

Just because ravenous miscounted does not make his suggestion wrong. Do as recommended.

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

If windows.h does not come with the compiler, downloading it won't help. You just can't use it.

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

Or, since now and bday are both in seconds, use subtraction rather than calling a function.

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

You need to stop thrashing about just trying things, and not understanding what you are using. Everything you need is in the time.h header. Find an explanation of the functions and structures it contains (GOOGLE) and read it. Then you will be able to do this task with ease. It's just a matter of calling the correct function to get your birthday value and subtract it from your TODAY value.

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

Use the character read from the file as an index into the array The Dragon mentions, and increment that value. Then when done, look through that array using an index and if the element is > 0, output the index as a character.

The Dragon already gave you the code.

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

1) Format your code properly -- How to do it. Concentrate in INDENTING.
2) We aren't Psychic! "there is still errors" is no help at all. Are we supposed to guess what the errors are?

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

Then convert all values into individual digits in an integer array. Then you can ignore the fact that floating point values are not exact.

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

How big is throw[] since i has no value?

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

You need to look at the format of your IF statements. They are malformed.

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

Sure. Try this

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

Open the .txt file for input
Open the .html file for output
Output the header
Read the .txt file
Write it to the output file
Close both

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

Why strtok() ? Use strstr() .

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

sorry, you maybe didn't see my edit, but would you be able to answer my other question? Thanks alot.

That's why you souldn't edit posts except to correct mistakes...

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

WaltP >> Sry, but your code won`t work, now I`m feeling such noob... :(

Maybe you did it wrong. As a noob, how can you tell it "won't work?" I've been using this technique for years. Maybe you need to describe what you don't understand about it.

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

Keep a flag:

EnterKey = 0
if character = [ENTER_KEY} then EnterKey = EnterKey +1

You'll have to figure out what causes the flag EnterKey to be reset to 0.

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

how can i make it correct???

By formatting the code so we can read and follow it.
By running it and seeing what it does wrong.
By looking at what it does wrong and finding the problem area.
By adding cout statements to see what variables are wrong at a given point in the program.

If you want our help
1) Format the code
2) Explain what the program is supposed to do
3) Explain what it doesn't do correctly
4) Tell us where the problem is

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

First off, your formatting makes your code difficult to read. See this for assistance.

hello everyone my aim is to count different words from text file and write them to output file with the number of occurences.but my code didn't work,I don't know the mistake but I think my read and write functions cause the problem.any help or suggestions?

We don't know the mistake either, since you didn't bother to tell us what the problem is. All you said was the equivalent of "My car won't move". Be explicit in your descriptions of the problem.

If you suspect the read function, display what is read. cout is the easiest debug tool available.

Also, I don't know about your native language, but in English, there is a space after the period (.) at the end of a sentence. English isn't a web address.

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

I do apologise if I am not using the CODE and the ICODE correctly.

This is a new one. Apologizing for not using something correctly that wasn't even attempted. Use Advance Editor would have told you immediately.

kvprajapati commented: Ha! ha.. HaPpY nEw YeAr sir :) +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I have no idea what your first code is doing. The loop makes no sense, neither does the output.

As for command line parameters, see this

And for your first post:
Code tags -- fantastic! Thank you!
Code -- fair attempt at formatting the code. Check this out for more complete details.
Comments in code -- wonderful to finally see! Thanks.

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

Output the character before returning, see if it's being read properly.

And see this about your scanf()

edit: think its ok, how come i had to put char graphic_choice( char x ),...

Because you are defining the function as returning a character.

... i didn't have to put this in front of any other functions?

Because your compiler sloppily allows untyped functions to default to integer without warnings. Check your compiler settings and turn more warnings on.

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

Other than using the non-Standard scanf_s() I don't really see a problem. Try displaying t[jcs] after the input to make sure it was input correctly.

More info is probably needed.

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

Hi,
many thanks My friend mrteey2k for your efforts and code
after i install all components as your design and run but i found some error
same that :
if you calculate that
2/11/2010 9:00am till 3/11/2010 4:50pm = 950 minutes (correct answer )
PLZ Be NOTe if we Calc again
2/11/2010 9:00am till 3/11/2010 5:50pm = 1010 minutes
why ???????

Plz be sure CODE will ignore all time after 5:00pm till next day

Many Thanks again

Look at the code an figure it out. We are not your personal coding service. You could have spent the last 10 days thinking rather than sitting on your butt hoping someone can do your homework for you.

I'm surprised andreRet even offered code. And mrteey2k, we do not do homework for others. We help them fix their own code...

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

Start with (in your case) the hardest test first.

if line is blank
   exit loop
else
   if line is #
      convert it
   else
      bad line
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Get the line then start testing. Don't get it in the IF statement.

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

I think it could remain a stickie. as for "confusing the newbies" I doubt it. They obviously just ignore them for the most part. Can't get confused when you don't bother to look... :icon_confused:

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

my problem is that i can input names into vector but how do i make it visible in other functions?

And how could parameter relate to your question?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
infile.get(c);
    infile.seekg(0, ios::end); 
    infile.seekg (0, ios::beg);

You're kidding, right? For heaven's sake why?

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

If I give the array size as 60 and if there are only 35 rows then for the rest of the array size junk value gets printed.
Is there a way to find the no of rows while the program is reading the file for the first time?

Are you really certain you can't figure out how to fix the junk values?

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

so now im trying to read integers from input untill input is eof or blank line(line was left empty and enter was hit) ... ive found some codes(getline ) but it only applies for char type ! and i dont want to go through the whole conversion thing(but if theres a simple one ill consider it) !

Why do you want to do it the hard way and not the easy way?

Read the line.
Test if it's blank.
If not, test if it's digits (this is simple).
If so, convert to binary (also simple, one statement).

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

Why read an entire line and step through each character when you can read each character and use it?

As for your last suggestion, how does it accomplish "count the frequency of each characters"?

That's all...

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

Do you know what a parameter is?

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

Do you understand arrays? Indexes? What more needs to be said?

If you have a specific problem, ask a specific question and show us the problem area. Your mechanic won't fix your car if it's in your garage, will he? We can't help with your code if all you tell us is "Well i have tried as what you have said but there is no any output."

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

All characters are also integer values. A=65, B=66, a=97, SPACE=32, etc. Do a search for ASCII CHART to see all the characters and their value.

With that in mind, you can use the character (value) as an index into an array. Each character increments the array element associated with it. There you have a frequency table for all characters in the file.

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

You forgot one step: If a "(" is found instead of a ")" after the first "(", then remember the new position and look for the next ")".

No I didn't. I said:
"Every time you find a ( remember it's position in the string.." You may have to remember 2 or more positions.

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

Be honest --
When did he dump it on you?
When is it due?

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

Start at the beginning of the string and look at each character.
Every time you find a ( remember it's position in the string.
When you find a ), evaluate the equation from the last ( to the just found )
Remove that equation replacing it with the answer just found.
Continue...

astala27 commented: Nice, you just express the algorithm +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That's because it's conio.h. But keep it commented out. You shouldn't be using it anyway -- it's not a standard header and if you get used to using it, when you change compilers you'll have problems because all your conio.h functions will no longer exist and you'll have to weed out all those functions from your program.

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

hi! iam a newbie how can i get the 10th, 100th, 1000th place for example: the interger is 1235, the ones place is 5, the tenth place is 3, the hundreds place is 2, and the thousands place is 1, please help me

Of course you're a newbie. Only newbies hijack other people's posts for their own questions. And then don't bother to try to answer the question themselves but ask here for free code. Of course, they also don't bother reading the other posts in the thread that already answer their question.

Jason Giggs commented: Nice One Walt +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Try this

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

So rather than trying to figure it out, you simply ask us to tell you? Maybe the task is to actually figure out how to find the answer.

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

Start outputting values to the screen.
Watch your loop value as it increases.
Watch your word value as it's tested.
Watch the character being looked at during each loop.
Run through the loop one character at a time (pause at end) and make sure all the values are as expected.

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

That depends on the compiler you are using. Would I be correct in assuming it's an old Borland compiler? 3.0 perhaps?

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

I'm sure the meaning can be found
1) in your book if you have one
2) in the tutorial you are using, if you are using one
3) from GOOGLE, which knows everything and can explain stuff better than we can.