Write a program that will allow a user to input his name. The prompt and input data would look something like this:
Please enter your name. Peter Ustinov
Using a for-loop and the String method, substring(...), produce a printout of the reversal of the name.
For example, the name Peter Ustinov would be:
vonitsu retep
Notice that the printout is in all lower-case. Use the String method, toLowerCase() to accomplish this.
>>41
You're the C reddit fag aren't you? get the fuck out
>>40 brat
I'm probably older than you! C++'s std::string is good
no it is not, i never said that did i? long parade of ignorance
englighten me. They're perfect yet str* let buffer overflows happen. Right on, fucker..
It's the code you wrote that allows it. Get a few more years of C under your belt and we'll talk again, okay?
...
Name:
Anonymous2007-09-27 13:45 ID:nT+xKl1i
no it is not, i never said that did i?
So why compare a C character array to to std::string, and then say that's the way it is?
It's the code you wrote that allows it.
Right, because you are perfect. You never make mistakes. You should not use tools that make those mistakes less likely. In fact, you are an awesome hard-core assembly nerd; only weaklings let a language construct a stack frame.
The moment anybody makes an argument related to programmer discipline, their argument falls flat. Why? Because if a novice can make that mistake, so can an expert. It's a question of probability, and it will happen.
I prefer to use tools that make certain bugs impossible. The only reason for null-termination is because they were faster on PDP-11s; pascal-style are superior in every way except for some rare niche cases.
englighten me.
Okay: The answer is yes but the function that changes the `size' of the string when it resizes is O(n).
Explain to me how a Pascal-style str.len is O(n)?
Concatenation has nothing to do with using len. They're orthogonal. How you conflate the two is beyond me.
If you want fast concatenation with Pascal strings, use exponential allocation. As a C programmer I'm sure you're aware of the whole "trade memory for speed" thing. And on a separate note there are also ropes?
And lastly, for your other example, take a gander at string slices. Of course, to get that you need a GC, which will never happen in C. Most C programmers are too busy being studly to use one of those.
Name:
Anonymous2007-09-27 13:49 ID:uhhj8YqU
>>42 C reddit fag
LOL who. Your imaginary adversary?
Name:
Anonymous2007-09-27 14:12 ID:NU5AkYZ4
Lol @ Cfag. This thread confirmed he's a 15 years old kid who uses inline assembly to write OMG OPTIMIZED shitty algorithms, and doesn't even understand the difference between length and concatenation, both of which by the way can be O(1) in better string systems.
He's 15 and can do things you can't even though you're probably 35. Shame on you.
Name:
Anonymous2007-09-27 15:57 ID:nT+xKl1i
>>46
Or, the more likely alternative, is that we've done assembly and moved on.
It's not the 80s and 90s, anymore. The main reason to write assembly nowadays is for SIMD or other instructions that are inaccessible to many languages.