Rashakil Fol 978 Super Senior Demiposter Team Colleague

So just run something like

perl -pi -e 's/foo/bar/g' *.cpp *.h

in every directory. Or maybe something like

find . -name "*.cpp" | xargs perl -pi -e 's/foo/bar/g'

assuming you're running in a unix-like environment. I'm sure you could do something similar in Windows. (Note that 'find' is different on Windows.)

For tasks like this, C++ is not the ideal language.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

From http://www.daniweb.com/forums/thread172120.html#post791196 :

On a side note, never throw exceptions from main(). Use a try-catch block.

Why?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Flow charts are basically an awful way to design a program and an awful way to represent the design of a program. If you asked me to name any "good" ways to _represent_ the design, I couldn't. But I think type systems are pretty good.

The very idea of just jumping in and coding is completely nonsensical. It's not like you just jump in and write code that (somehow) will lead you to the solution. You surely need think about what information you will be manipulating and how you will communicate information first. The phrase "what information you will be manipulating and how you will communicate information" is also called "the design".

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If there is not such utility - then - can someone make it - because it's a simple task for a programmer - surely - a small exercise.

Then why don't you make it?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You have a variable there that keeps track of the sum of the numbers. Using the same pattern, make another variable that keeps track of the largest number seen so far. Initialize it with the value Integer.MIN_VALUE.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I think it would help if you specified more precisely what you expect the input text to be, and gave examples.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Read your lecture notes and read your textbook. Write simpler programs and grow them into something bigger with progressive, understandable modifications.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

that's the main thing there are so many classes that it is impossible to save them in an array but some variable names

We're getting somewhere. Is there a particular reason you need to write this in C++? Would a solution that doesn't use C++ suffice?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I don't see where I'm making it easy to discredit my point of view, and if you consider that advice like on questions like these may affect how people behave for months or even years, it is reasonable to get emotionally invested in the answer.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Rashakil : Please stay polite, your answer is very non professional.

I am a professional programmer, so that means my answer is by definition professional :P

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why ?

Database programming? Seriously? I don't think the answer to being good at C# is to start with database programming. You need a good sense of algorithmic complexity, formally educated or informally comfortable, to be good with databases, and somebody starting off with "database programming" will end up just guessing what is a good idea based on some set of arbitrary rules and pattern matching on other examples, without understanding things deeply.

If you imagine one person starting with database programming and another starting with C# and focusing on how to translate algorithms from their brain into code, the latter will progress more quickly.

At some point, though, in the middle, adding database design to the roster is a good idea, at least because it adds some variety of experience in dealing with structures of information.

look at FTP, Filestreams etc...

"look at FTP" and "look at Filestreams" is just absurd. FTP is irrelevant and filestreams are a trivially easy piece of library.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I just used Emacs for it.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

i'm trying to insert comparecount and movecount in the program.

I do not understand this sentence.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can look inside the file and see what's there. If it conforms to your expectations -- if the file or the first 1000 bytes of the file contains only characters that conform to one of some particular set of character encodings, maybe you have a text file.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

cVz's advice is horrible.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can usually find answers on wikipedia.

http://en.wikipedia.org/wiki/Hamiltonian_path_problem

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yes, but the string might contain of a substring where only the substring needs to be replaced. For example, in "Hello.World" being one whole string I only want to replace World with "Earth".

What you described (only replacing the "World" part with "Earth") is equivalent to replacing the whole phrase "Hello.World" with the phrase "Hello.Earth".

There are plenty of tools that can do search and replace across a directory for you.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Lighten up, dude. There are not actually very many interesting projects to do involving something as staid as applied mathematics.

Salem commented: Go on, guess -6
Rashakil Fol 978 Super Senior Demiposter Team Colleague

>Perhaps he comes from some inferior culture that has a notion of "face".

There you have it, ladies and gentleman. A level headed, well reasoned, "relevant" defense of Narue. BTW, Rashakil, you wouldn't happen to BE Narue, would you?

No, I just happen to enjoy exponentiating irrelevant conversations.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It depends on the users you have. Most sites accept some standardized syntax for input. For example, Daniweb lets you use LaTeX:
[tex]\int_{-\infty}^\infty f(t) e^{- i t \omega}\,dt[/tex]

If you needed to parse the expressions and do computation or manipulation with them, you might use a different, simpler syntax.

The other option is to have some interface for manipulating expressions. This kind of GUI could certainly be done using Javascript! That would be the best method. However, it would be easier for the programmers to let users input expressions in some simple form like S-expressions (* 2 (+ 3 (^ x 2))) and give them the ability to preview the results.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The original poster is a head case. He completely irrelevantly mentioned his familiarity with English and then started complaining about straightforward replies as if he had been slighted. Perhaps he comes from some inferior culture that has a notion of "face".

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I still don't get why you bother adding zero.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Applications run by the operating system can't access hardware directly. Instead, they have to access it through system calls, and there is some sort of protection that prevents them from doing things like, say, writing random bytes to the hard disk or sending arbitrary signals to the ethernet device. This protection is put in place by the operating system.

For that reason, writing applications (in assembly or another language) is a level of abstraction above writing operating systems.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

He is not a mean. Did you even read the conversation?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

But when a static variable is required, then that is completely different. This way ALL calls to the method regardless of instance have the same static variable.

Yes, we know what a static variable is.

That is typical for specialization of event type in a monte-carlo, base-class has getCell and specialization class knows about the event that can take place, the new energy/velocity of the particle.

I have no clue what you're talking about.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It's not that counterintuitive.

Yes it is. Having functions secretly behave differently depending on invisible environmental variables is tremendously counterintuitive.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

A better solution would just to make that variable a member of the class. Yours would require extra code to check that the same class is receiving the call as before. And it wouldn't be thread safe.

But okay, unnoticeable static variables are pretty reasonable. C++ makes doing things a more safe way (regarding risk of bugs) so awfully verbose that I can understand.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

No, and even if it were possible, it would be completely counterintuitive.

Also, it's completely unnecessary. Instead, pass a parameter that tells how you want the function to behave.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It depends on the requirements for the game.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

0x3A28213A
0x6339392C
0x7363682E

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The ability to have static variables in the middle of functions is a crufty feature left over from the old days of C.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm guessing it would just act like a static variable. I wouldn't make use of it at all -- put any static constants you have in your class definition and don't use static variables.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm pretty sure you need to take the individual sample values and scale them up (or down).

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why do you say static variables will be disposed of at the end of the function call?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Are you just asking how to do a straight string search and replace?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Well i guess you can read each line of the file with getline functions and then search for each of your words inside the string. If it is found. you can use the erase function to remove that particular part of the string and then you can now insert your new word in its position.

No, that would be dumb -- you would end up breaking anything with the same name that belonged to another class.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Another option is to just change the definition, try compiling with a compiler, and look at the compiler errors.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Use an IDE. They have features like automatic method renaming.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You see scheme. So I need a recursive class or something like that.

What the fuck is a recursive class? What the fuck are you talking about?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yes. In general, you should make a function

int random(int n) {
    return (int) (n * (rand() / (1.0 + RAND_MAX)));
}

and use that to generate a random number from 0 to n-1. With a decent random number generator, it's as good as rand() % n , but with a typically bad random number generator (which you might have) it gives better pseudorandomness. As with rand() % n , it's only good when n is significantly less than RAND_MAX -- how much less depends on what you're using the random number for -- if you do the math yourself, you'll see how different values have different probabilities of getting returned.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The "From" header contains the alleged email of the sender, yes.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The program has finished, so the window closes.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Is anyone else using IE?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You could, say, make an application for easily designing (and running) _______ simulations in ______ environment. Insert an appropriate word pair like ("swimmer", "low-reynolds newtonian fluid"). That's more on the computational end of the spectrum -- depending on your department's definition of "applied mathematics" that might be fine. (My math department, for instance, had "applied" a separate concentration from "computational".)

Another option might be to make a video game whose physics requires some form of "cool" numerical computation. Again, I'm thinking something involving simulating a (2D) fluid somehow (because it would look cool if you rendered it right, and because I (with another fluid simulation idea) have a limited imagination).

I guess in general I would take a look at the problems that applied mathematics is good at solving and seeing if you can squeeze that into something interesting.

Now, if you only need a general math theme (and not an applied math theme) you could shoot in the direction of a computer algebra system, or something like a raytracer (with good features). I think a ray tracer's a pretty good one, because you automatically get linear algebra, problems like the representation of geometric shapes, and if you include support for things like transparent objects with continuously varying refraction indexes, some numerical computation.

If you wanted to be fancy, you'd do raytracing on a 3 dimensional manifold embedded in 4-D space.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

cool - please mark it as solved

Why are you so keen on having people mark threads as solved?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Wireshark.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Well it seems you didn't read my reply, so never mind.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What the fuck? Your random function isn't random any more.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Fantastic, Rashakil! Thanks for your explanation. Just so I can say I have some sort of "understanding" of this---pointers could be dangerous because if the 'variable' I told the pointer to attach to goes away, the rest of the program would act up?

Yes. Here's an example.

int* foo(int x) {
    int y = 3 + x;  // contrived example
    return &y;  // the variable y will no longer exist when the function returns.
}
void bar() {
    int* p = foo(4);
    int k = *p;  // undefined behavior, but probably k will contain 7.
    blah();  // almost certainly overwrites the value p points to.
    int j = *p;  // j is probably not 7.
    // ...
    something(p); // hilarity ensues
    // ...
    // ...
    // possible alternate error:
    delete p;  // oops, forgot whether p was pointing to the heap or stack   
}

I disagree with rashakil. Using pointers properly can greatly increase the efficiency and speed of your code.

You might not even be disagreeing with me depending on your definition of "properly", but I hope you're not implying that pointers are reasonable to use in place of iterators and smart pointer classes.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Your problem is that you're recreating the file every time through the loop. Thus, the old data gets replaced.