WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
while not end-of-string
    read character
    if character not = SPACE
        store character
end while
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Java, python, perl, c, c++, algol, pascal, basic, snobol, lisp, pl/1, cobol, bliss, etc, etc...

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

Try this:

Initialize all values as 'prime'.

Outer loop [B]val1[/B] from 2 to [I]whatever[/I] 
    Inner loop [B]val2[/B] from [B]val1[/B]*2 by steps of [B]val1[/B]
                                   // skips the number itself ...
        sets value to 'not prime'  // ... and sets each multiple thereafter
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I've tried adjusting the modus for file reading/writing, but it did not solve the problem: the file copy is still stopped after 705 bytes.

Then you didn't fix the problem properly :icon_wink:

If I understand correctly, the difference in speed between fread/fwrite and getc/putc is the same?

You understand incorrectly. getc()/putc() is slower because it reads one byte at a time. fread()/fwrite() can read multiple bytes so it's much faster.

But isn't the getc opening the file each time it gets a character and then reopens the stream, in contrary to fread that would only need to access it one time? I think I'il try the fread/fwrite method in this case.

No, if getc() opened the stream every time you'd only be able to read the first byte of the file.

Assuming I find a solution to the EOF problem (probably using fseek, suggested by DeanM),...

Worthless and makes your code too complex. Just read a block, write a block, read a block, write a block... Keep it up until fread() returns EOF.

... will fread work correctly with really large files (e.g. 3GB +), as it would allocate an absurd amount of virtual memory if it does it all at once. Would it be better to do read/write every 50MB or so? Or should I depend it on the virtual memory available (and if so, how do I measure it with standard C functions)?

Read the file in small enough blocks that
1) it doesn't …

Graphix commented: Constructive! +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

ID = 1;

After reading a person
ID++;

All you have to do is think about it...

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

The explanation is only weird for the first time. i.e. ++a + ++a = 14

So lets say you add one ...

Lets say you want to print the value of a ...

I hope I am able to give some justification to it.

No, you gave no justification for anything. You didn't bother to learn anything from the rest of the thread, specifically:

...but such expression behaviours are not defined by standards.
http://c-faq.com/expr/ieqiplusplus.html

The result of an undefined expression could be anything until you actually run it, and the result you get in practice depends on too many factors to be predictable. Results that aren't predictable and can't be controlled are undesirable, right?

The value cannot be determined with any surety. See this

What part of these posts did you not understand?

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

Get rid of that complex FOR statement. Doing 2 fgets() in a FOR statement is a recipe for disaster. Keep your code simple.
Pull those 2 reads out and put them in the loop itself.

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

Create a loop.
If they enter an invalid value, stay in the loop.
If they enter a valid value, exit the loop.

deceptikon commented: Not what the OP asked for. -1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Start the number at 1.
Every time you input a patient, add 1 to it.

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

Try outputting the characters in hex just before the test, and which block was entered.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
if (isalpha(charValue))
{
    // charValue is an alpha
}
else
{
    // charValue is not an alpha
}

Returns TRUE if charValue is A-Z or a-z
Returns FALSE if not.

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

sci@phy, did you really understand the problem?the answers you have written is vague and may be equal to knowledge of a child in programming. If you can not answer properly, do not answer it just to show that you are an intellectual.

Is there a reason you resurrected a 4-year old thread just to scold someone that hasn't been here sin Oct 13th, 2010?

Let sleeping threads die...

What is the Josephus problem?

Clickity Click

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

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@WaltP:
i am not saying that if java does not support than c# should not. I mean to say is java has eliminated the concept of operator overloading and than too we don't need any operator overloading there.

Nitpick: When did Java eliminate overloading? What version of Java took it out of the definition?

Be careful with your wording...

So, why we use it here?

Simplistic answer: Because when C++ was defined overloading was a logical enhancement to the object concept. Why have objects if we can't define operators to operate on them?

Well, i think operator overloading is required when we want to do some operation by creating more than one class objects so that it becomes easy to pass data to function. An i right?

Not a clue what you mean.

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

Given i = ++i; Does ++ change i?
Does = change i?
If the answer is yes to both, undefined.

Why would it be different from i = i++; ?

PrimePackster commented: That was easy to understand... +3
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi all..
How i can make a report without using database.
Data can directly from the active form.

Thank you in advance

If the form has all the info for the report, just start outputting the info the way you want it.

If that doesn't help please give some details.

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

But we can do these without overloading also.

Sure. We can make a function: CAR AddTwoCars(CAR vehicle1, CAR vehicle2, CAR vehicleNew) which 'adds' #1 & #2 and returns the new one. Or we can overload the + operator and have: vehicleNew = vehicle1 + vehicle2;

Java do not support operator overloading so why to do in c++ and c#? I am not getting the actual usage.

So if Java doesn't do something, C++ and C# shouldn't either?
Well, ForTran doesn't have classes and pointers. Why should Java, C, C++, C#, Python, ...?

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

Because y is modified twice. See this.

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

In other words, simplistically, it's a way to define what ==, <, >, etc are meant to be for a class that you define yourself.

Example, you have a class of CAR which contains
Make
Model
Year
Price

You can define operator= to mean:
Same Make
Same Year
Price is within $1500 of each other.

Of course at thines01 said, you can also define how to ADD and SUBtract two cars -- whatever you think that would mean...

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

Completely depends on what's wrong. This will help...

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am getting compiler errors

Really? That's too bad. Could you turn your screen a little left so I can see what the errors are?

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

Ahhh, now I see the problem. I didn't look close enough.

... but it moves a line down every time it encounters a white space.

That's the definition of a read using >>. If you want to read a line you need something like getline() .

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

That's because you read the number from your input but not the NewLine you also pressed. Loop up cin.ignore ...

I'm surprised the _getch didn't do the same thing...

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

So when you get there, you can continue with this program, eh? :icon_wink:

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

So where do you need the endl? How do you know when that spot is read?

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

But what is the point of dynamic memory for a single type?

Exactly...
For a single type, it's a waste to use dynamic memory. I can't think of any reason why one would need to dynamically create an int or float.

Do you mean if i were to declare an object with dynamic memory within a particular function it would be available within another function?

If you pass it to the function, sure...

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

Thoughts? =)

Either.
Which seems easier? More straight-forward?

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

out_stream<< next<< endl; -- what does endl do?

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

ok , i did that, but it's still doesn't recognise 'i' in the second for loop.

That's because you didn't define it in the second loop. You only defined i in the first loop.

(Yeah i know i shouldn't be using _getch(), i'll get around to sorting that out.)

Why "get around" to it? Just use cin.get() and be done with it...

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

No, I realize that much. I can't organize it in my head. I need this spelled out for me, more than that. Thanks though. Couldn't have guessed, right? I need details.

That's what pen and paper are for. To organize it so you don't need to keep it in your head. It's called design and desk checking. Your head is a terrible designer/organizer.

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

Think about it! What did you do for matrix?

Write the loop out on a piece of paper and follow it with a pencil, changing i,j,and the index and you'll see what's wrong.

This is called desk checking and is the single greatest debugging aid you can use. Printing the values like you did is the second.

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

Always use { } to make your code readable and consistent.
This then no longer will be a problem.

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

So fix it.

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

So when you find a / read the next character.
1) If it's a *, read until */
2) If /, read until EOL
3) If neither, continue on.

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

Oops, I just saw the problem.

During the loop, what does i+j equal? Print it in your cout

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

My quess is it depends on what N and M are...

matrix[i*N+j] = (double) array[i+j];
                ----^---

Why? Aren't they both doubles?

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

Time to back up...

Read a line
Search for // then /*
If you found one of them, process that comment style.
If you found both, which one's first? Process that one only.

If you get a // the rest of the line is a comment -- done.
If you get a /* search for */ -- everything between is a comment
-- if */ not found, read another line and search again. Keep it up until you've found it.

Remember, this is legal:

if (val /*the number being tested*/ != 0 /*has a good value*/ (
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First thing's first. As mentioned, use proper FORMATTING. See this.

Without consistent formatting, trying to follow and understand someone else's program is difficult. If you need help, help us, too.

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

1) Format your code
2) main() is not a void
3) Don't use conio.h because it's non-standard and only a couple compilers have it defined
4) The .h version of C++ headers have been replaced years ago

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

Sure. You probably changed something and broke it.

Hope that helped.

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

Which date? Creation? Last Write? Last Access?
All seem important to me, albeit to differing degrees.

And what are you considering a header?

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

Great! You should have said so and mark the thread SOLVED...

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

Get rid of all the hex and tell us exactly what you want... using ASCII.

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

It also helps to comment your own code. Then you can use it to test itself.

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

1) USE CODE TAGS!
2) Format your code.
Almost all errors like this can be avoided by proper formatting.
3) Never tell us what the error says, post it verbatim (copy/paste)

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

Much better. I assume it's working fine now?

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

And what if you aren't using decades-old technology? What if you're using any compiler released between 2000 and now? Or even any old compiler that isn't Turbo?

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

I thought the program was supposed to fix the spaces via programmer code, not C++ I/O idiosyncrasies. One learns more by doing it old-school.

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

Sure.
strcmp
strchr
strcpy
strncpy

4C617A79206275747421

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

I don't understand the need to break the input into words. Just make sure the first letter is capitalized and set all other letters to lower case. Doing it word by word is meaningless and makes the job more complex.

Go through the sentence and fix capitalization.
Go through a second time and remove extra SPACEs.

So this program is supposed to take in a sentence and output it with correct spacing and capitalization.

The program is supposed to fix spaces between the sentences to make sure there is just one.

I assume in the second quote you meant word, not sentence, correct?.