Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

c++

Name: Anonymous 2009-09-23 18:37

im new to c++ and have a little problem with a project. I need to read the input from the user that follows the following format.. LETTER SPACE NUMBERS .. The only method we've learned so far is cin for reading user inputs, and cin will only read the letter since there is a space in the user input. I've googled a bit and found the function getline, but now I don't know how to read what letter they entered and the number separately... help.

Name: Anonymous 2009-09-23 18:58

Lrn2regex

Name: Anonymous 2009-09-23 19:03

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

Name: Anonymous 2009-09-23 19:15

>>3
Some people, when confronted with a regular expression, think "I know, I'll have two problems." Now they have three problems.

Name: Anonymous 2009-09-23 19:16

>>3
If it will be on Sepples, I'd say he has at least 4 problems

Name: Anonymous 2009-09-23 20:01

public defun numProbloms ():
    c++ where on c() &numProbloms.

Name: Anonymous 2009-09-23 20:10

>>6
What manner of trickery is this?

It looks like FIOC, SEPPLES, ENTERPRISE, and LISP all at once.

Name: Anonymous 2009-09-23 20:49

>>7
Relax, it's just the inside of a loop macro

Name: Anonymous 2009-09-23 23:39

>>3
truth and lol

Name: Anonymous 2009-09-24 7:34

>>5
Wait until he learns about Boost.

Name: Anonymous 2009-09-24 7:35

whats boost lol xD

Name: Anonymous 2009-09-24 7:55

>>12
boost is so random xD

Name: Anonymous 2009-09-24 8:04

char c;
while((c == getchar() != EOF){
//do whatever with characters
}


*sigh*
sepples users.

Name: Anonymous 2009-09-24 8:05

>>14
damn, i left out a closing parenthesis

Name: Anonymous 2009-09-24 8:39

>>14
I'm in the middle of K&R, but what's wrong here?

Name: Anonymous 2009-09-24 8:47

>>16
I'm not >>14, but it should probably be:

char c;
while ((c = getchar()) != EOF)
{
// handle character here
}


=, not ==

Name: >>14 2009-09-24 8:50

>>17
gah, i should really double check my code before posting it on /prog/.
that's two mistakes now

Name: Anonymous 2009-09-24 9:03

Wonderful example of how shitty the C family is. Thanks guys.

Signed,
just another schemer

Name: Anonymous 2009-09-24 9:09

>>19
Wonderful example of how shitty the C family is.
what is?
the fact that there's about 20 ways to take input, but OP only learned one?
or the fact that it's possible to make careless mistakes in your code?

silly functional programmer, nobody uses your languages for anything except calculating factorials.

Name: Anonymous 2009-09-24 9:41

>>20
I'm not >>19, but you simply have no idea what true high level languages can do. You simply cannot convience what they can do and how practical they are. I could give you so many examples, but you probably wouldn't understand them, since you probably only know one(or more) low-level imperative languages, which limits the way you think about things.

I'll give you a practical example:
Error handling:
In C you call a function, and can get a result from it, you may also check the result against some magic constants to check for errors in the execution of your function. So you've conflated a return value with an error code, this isn't `the right thing to do'. What if I want error handling to be done transparently, and so that I won't have to spray my code with:

int status;
status = fun(...);
if (status == ...)
{
... handle error...
} else if (...) ...
actual_result_type actual_results = (actual_result_type*)status;
...

What if my return value may match the error code as a valid return code? What if multiple errors happened at the same time? What if I can't write a handler here as the actual logic which needs to decide on how the error should be handled is actually some place higher in the stack? What if I don't want to unwind the stack when using exception handling, because that would cause important information to get lost, and a continuable error may turn into a real error without it being one? What about being able to gracefully restart? And so on.
You want a real condition system! You want multiple return values, and not a hack which involves using pointer parameters to return values!

You cannot concieve what can truly be done, because your language limits the boundries of your thoughts. Even if you can do all these things in C, you'll never do them as they're TOO MUCH WORK. Sometimes people actually greenspun such things in C, and create wonderful high-performance applications, but they usually take many years and dozens of contributors. Something which could be achievable in Lisp in months by one or two persons actually takes many years of work and dozens of contributors to reach that state.

I'll stop here for now, otherwise if I start talking about macros, compiler macros, reader macros, closures, the condition system, a truly dynamic environment and many other wonderful things, it will simply take too long.

Name: Anonymous 2009-09-24 9:41

*concieve

Name: Anonymous 2009-09-24 9:49

>>21
Wow, YHBT.

Name: Anonymous 2009-09-24 9:51

>>21
well, i know haskell.
i still think functional programming languages are not fit for real work use though.
you do realise that all the stuff you are complaining about is STILL going on in the backround, right?
just because your language babys you doesn't mean it's any different when it gets down to the nuts and bolts

Name: Anonymous 2009-09-24 9:54

SEPPLES

Name: Anonymous 2009-09-24 9:55

>>24
s/real work/real world/

Name: Anonymous 2009-09-24 9:59

>>24
I'm not talking about pure functional programming. Haskell is fine, but I don't consider it the most pragmatic programming language. What I had in mind was Common Lisp. It's not really about babying here, it's about engineering solid software. If you write a macro which allocates and deallocates a resource for you, as well as adding all the needed error handling code, you can be sure that as long as you write the macro correctly, all your code using it will not have errors of that kind. In C, you have to malloc and free carefully, check return types, and so on. You waste your time writing a lot of boilerplate code when you could teach your language to write for you, once and for all, it's just not good use of your time to do that. You're doing the job of the machine by yourself, and this can lead to errors as we're humans after all.

Name: Anonymous 2009-09-24 10:09

>>27
well, you make a good point.
i'm still unconvinced though. i rather enjoy all that stuff, and i find it's not as satisfying to do it your way.

Name: Anonymous 2009-09-24 10:28

>>28
People like you are why most software sucks.

Name: Anonymous 2009-09-24 10:40

>>29
people like you are why computer programmers are getting stupider and more clueless every year.

Name: Anonymous 2009-09-24 10:55

hay everybody, lets create more abstraction!
who cares if everybody will forget things like how to write a kernel, lololol, that stuff is for eggheads. asm, C? too low level, completely useless in this day and age - only fools use it, too easy to make mistakes!
writing code needs to be easy! i want my baby to be able to replace me at my job.
to write a computer program, all you should need to know how to do is type. ammirite?
hey, hey, if we ever need to write an operating system again we'll just write it on top of an existing one - like a wrapper. a wrapper around a wrapper around a wrapper around a wrapper. who cares if it'll become exponentially more slow with every layer of abstraction, the point is that it's easy and you can't make mistakes XXXDDDD

Name: Anonymous 2009-09-24 10:58

>>31
You're incorrectly assuming people don't know Assembler and C. I actually learned x86 asm and C before I learned Common Lisp.
You use the language fit for the job.
Coding something which is clearly high level in a low-level language is waste of programmer effort, and will only make your software less reliable in the end.

Name: Anonymous 2009-09-24 11:05

>>32
if this IS the truth then stop making it sound like you think everything except for your precious lisp should be abandoned.

Name: Anonymous 2009-09-24 11:13

>>33
The point is not about abandoning intimate knowledge, the point is about being productive enough to get work done ASAP. It's about knowing when and where to invest effort. An analysis of the problem domain will show how much effort would be needed for the performance requirements.

Name: Anonymous 2009-09-24 11:40

>>34
As we say: the right tool for the job.

Name: Anonymous 2009-09-24 12:02

>>33
No one says this. Lispers suggest lisp is almost always the best tool for the job, because most programming discussions are about tasks that don't receive any benefit from see.

Name: Anonymous 2009-09-24 12:12

>>36
..and thats why Ruby is more popular than Lisp.

Name: Anonymous 2009-09-24 12:14

>>37
It doesn't bother me that one high level language is more popular than another. It bothers me that anyone considers ever starting new projects in C or C++.

Name: Anonymous 2009-09-24 13:44

>>37
QFT
FTQ
TQF

Name: Anonymous 2009-09-24 14:03

>>38
It bothers you that other people have needs different from your own?  And that they choose the tools that meet those needs?  Seriously?

Name: Anonymous 2009-09-24 14:37

>>39
Q
Stopped reading there.

Fuck this letter. This is the shittiest character in the world. People who open their posts with it deserve to die.
This horrible letter doesn't merely mean that the post is devoid of any form of kality, it also means that your post is actively trying to skuander my precious time.

Name: Anonymous 2009-09-24 14:53

>>41
Are you a Queer?

Name: Anonymous 2009-09-24 15:36

>>41

Hmm. I think I like it.

Name: Anonymous 2009-09-24 16:09

>>40
I didn't say that. I said it bothers me that people consider starting new projects in C or C++. There is no need for that. Well, maybe C, for microcontrollers, but EE guys don't usually hang in ihbt.

Name: Anonymous 2009-09-25 4:55

>>44
What is they have a project that can't be SLOW AS FUCK

Name: Anonymous 2009-09-25 6:24

>>45
That explains C, but still not Sepples.

Name: Anonymous 2009-09-25 6:29

>>44
Agreed. Programming in C++/C or even Java is like being flogged with a warm lettuce.

Name: Anonymous 2009-09-25 14:25

>>40
More likely it bothers him that programmers assume C or C++ is suited to their needs, even when it patently isn't. That people have no idea what their needs actually are.

Name: Anonymous 2009-09-25 14:57

>>48
More like people don't know programming, so could not even properly evaluate a language to suit their needs, even if they understood their own needs, which they don't.

Name: Anonymous 2009-09-25 18:14

I rage at all these people who write their programs in C++ when it's patently obvious they ought to be using Fortran!

Name: Anonymous 2009-09-25 19:23

>>47
This is exactly why I do it.

Name: Anonymous 2009-09-25 19:33

>>50
F77 or F90?

Name: Anonymous 2009-09-25 20:33

>>52
If your compiler can handle it, taking advantage of features all the way up to F95 should be nothing but an advantage for everyone involved.
That you're doing high-performance scientific computing certainly shouldn't be a reason not to have recursive functions and a FORALL statement.

Name: Anonymous 2009-09-25 21:03

Functional programming is for babies who are unable to understand intensely difficult subjects such as what an integer is and how many bits in a byte.
It's the cancer that's killing programming.
You think Java developers are idiots? Just look at your average schemer.

doh ho ho.
In the real world functional programming is a joke, and functional programmers are village idiots.

Name: Anonymous 2009-09-25 21:16

Fortran is the best anyway.

Don't change these.
Name: Email:
Entire Thread Thread List