|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On December 11 2012 19:07 Tobberoth wrote:Show nested quote +On December 11 2012 18:58 lonelyPotato wrote:On December 11 2012 18:55 Tobberoth wrote:On December 11 2012 18:53 lonelyPotato wrote:On December 11 2012 18:50 tec27 wrote:On December 11 2012 18:45 Tobberoth wrote:On December 11 2012 18:31 Coal wrote: Hello! I just started playing around with HTML for fun (I intend to learn how to create simpler websites one day), and I have a question. Since I just started, should I learn HTML or HTML 5? What are the differences between the two?
HTML5 and HTML is the same thing. HTML5 is just the most recent version of HTML, what you mean is probably HTML4 which is old. The differences are usually pretty minor, HTML5 just have some extra tags to work with. Obviously, there are huge differences in the background though. You should definitely learn HTML5, everything else is outdated, including XHTML. This. 100%. lonelyPotato, please don't give advice about things you don't understand. HTML5 does include some features/tags that aren't currently well supported in all browsers, but these are mostly extravagant things. For basic tags, all modern browsers will support them just fine. If you do get into learning about the more advanced stuff, this site: http://caniuse.com/ is really useful for figuring out which browsers support what. I don't really know what I said wrong? Basically, recommending someone to learn HTML4 over HTML5 is like telling someone who wants to learn photoshop that it's better to learn it using Photoshop CS3 over using CS5. It really makes no sense why you would want to learn using an old outdated version of something. It's not like HTML5 is more complicated, anything written in HTML4 can be rewritten to HTML5 and will look better in the process, such as the new Doctype etc. True, you didn't have to say I didn't know what I was talking about though. I stated the difference between the languages and what I found different. Honestly, HTML 4 elements were for me easier to use, and if you want to get a solid understanding of Web based programming you should have a solid understanding of both of the versions elements, especially since so many people still are using HTML 4. I never said you didn't know what you were talking about, I agree with the person saying you gave bad advice though. I don't see how HTML4 elements can be easier to use, HTML5 uses the exact same elements, the only difference is that you can add in extra elements if you want, such as <section>, <header> and <footer>. If you have any idea how tags work, which you should obviously learn if you learn HTML, you realize that that these tags, all tags, are extremely simple. Outside of CSS usage, it's just basic semantics. "I want my email in the footer of the website, maybe I should add it in a <footer> element at the bottom so I can later style it". Perfect. You can put it in a div in HTML4 for the same reason if you find that simpler for some reason, but nothing stops you from doing that in HTML5 if the <footer> tag scares you. As for a lot of people using HTML4, that's true. A lot of people still use outdated versions of Internet Explorer. Just because other people are dumb and ignorant doesn't mean it's a good idea to go that route yourself.
It's nothing to do with being dumb, it's to do with cost and minimizing web disruptions. I won't put it up at the level of IPv6 in terms of disruptions, but it's partially a similar reason why people won't switch to that.
They go by the theory, why fix something that aint broke.
|
On December 11 2012 19:11 lonelyPotato wrote:Show nested quote +On December 11 2012 19:07 Tobberoth wrote:On December 11 2012 18:58 lonelyPotato wrote:On December 11 2012 18:55 Tobberoth wrote:On December 11 2012 18:53 lonelyPotato wrote:On December 11 2012 18:50 tec27 wrote:On December 11 2012 18:45 Tobberoth wrote:On December 11 2012 18:31 Coal wrote: Hello! I just started playing around with HTML for fun (I intend to learn how to create simpler websites one day), and I have a question. Since I just started, should I learn HTML or HTML 5? What are the differences between the two?
HTML5 and HTML is the same thing. HTML5 is just the most recent version of HTML, what you mean is probably HTML4 which is old. The differences are usually pretty minor, HTML5 just have some extra tags to work with. Obviously, there are huge differences in the background though. You should definitely learn HTML5, everything else is outdated, including XHTML. This. 100%. lonelyPotato, please don't give advice about things you don't understand. HTML5 does include some features/tags that aren't currently well supported in all browsers, but these are mostly extravagant things. For basic tags, all modern browsers will support them just fine. If you do get into learning about the more advanced stuff, this site: http://caniuse.com/ is really useful for figuring out which browsers support what. I don't really know what I said wrong? Basically, recommending someone to learn HTML4 over HTML5 is like telling someone who wants to learn photoshop that it's better to learn it using Photoshop CS3 over using CS5. It really makes no sense why you would want to learn using an old outdated version of something. It's not like HTML5 is more complicated, anything written in HTML4 can be rewritten to HTML5 and will look better in the process, such as the new Doctype etc. True, you didn't have to say I didn't know what I was talking about though. I stated the difference between the languages and what I found different. Honestly, HTML 4 elements were for me easier to use, and if you want to get a solid understanding of Web based programming you should have a solid understanding of both of the versions elements, especially since so many people still are using HTML 4. I never said you didn't know what you were talking about, I agree with the person saying you gave bad advice though. I don't see how HTML4 elements can be easier to use, HTML5 uses the exact same elements, the only difference is that you can add in extra elements if you want, such as <section>, <header> and <footer>. If you have any idea how tags work, which you should obviously learn if you learn HTML, you realize that that these tags, all tags, are extremely simple. Outside of CSS usage, it's just basic semantics. "I want my email in the footer of the website, maybe I should add it in a <footer> element at the bottom so I can later style it". Perfect. You can put it in a div in HTML4 for the same reason if you find that simpler for some reason, but nothing stops you from doing that in HTML5 if the <footer> tag scares you. As for a lot of people using HTML4, that's true. A lot of people still use outdated versions of Internet Explorer. Just because other people are dumb and ignorant doesn't mean it's a good idea to go that route yourself. It's nothing to do with being dumb, it's to do with cost and minimizing web disruptions. I won't put it up at the level of IPv6 in terms of disruptions, but it's partially a similar reason why people won't switch to that. They go by the theory, why fix something that aint broke. It's one thing not to fix something old which works, and another to build something new in something old when a superior new version exists. If you have a 5 year old complex webpage using HTML4, you're obviously not going to force a rewrite to HTML5, I sure as hell don't do it at my job. If you're LEARNING HTML though, there's literally no reason what so ever to learn HTML4 over HTML5. Especially since you'll have no problem working with old HTML4 pages just because you happen to know HTML5.
|
On December 11 2012 19:08 AmericanUmlaut wrote:Show nested quote +On December 11 2012 19:00 lonelyPotato wrote:On December 11 2012 18:56 AmericanUmlaut wrote:On December 11 2012 18:43 lonelyPotato wrote:On December 11 2012 18:31 Coal wrote: Hello! I just started playing around with HTML for fun (I intend to learn how to create simpler websites one day), and I have a question. Since I just started, should I learn HTML or HTML 5? What are the differences between the two?
HTML 5 offers better error handling (Corporations used to have to reverse engineer through HTML 4 code, that's not as much of an issue any more), better defined semantics (Basically means your code becomes a lot more organized), and also has lots of small little added features that allow for a more dynamic feel to your website rather than having to use little third party programs to do so. I am not a professional with HTML, but I have done a course for it at university, and personally I find HTML4 easier to use than HTML 5. So for a learning platform, I would learn HTML 4 first, and if you like what you see, you can make the jump to HTML 5 with ease if you have a solid understanding of HTML 4. If you want more information then don't be afraid to ask. Almost nothing you said in this post is accurate or useful. Wait are you serious! HTML doesn't offer better defined semantics? Are you really saying that is wrong? Are you saying that HTML 4 Wasn't retardedly hard to reverse engineer relative to that of HTML 5? Are you saying that HTML 5 doesn't offer a more dynamic feel without having to access third party programs? How is any of what I said wrong? How does HTML 5 offer better error handling? HTML is a markup language: it has no error handling. What do you mean by "reverse engineering"? You don't have to reverse engineer anything in HTML. Reverse engineering means looking at a result and then creating a system to generate that result, that doesn't even make sense as something that you would do in the context of HTML, which is served in plain text - if you want to know how a result is generated, you read the served markup. How is HTML4 "easier to use" than HTML5? HTML5 is basically a superset of HTML4, so you're saying it's easier to learn a subset of a language's features, but that's self-evident, and the way you write it implies that writing markup to generate a result in HTML4 is simpler than writing markup to generate the same result in HTML5, which is absurd because HTML4 markup works in an HTML5-compliant browser. Edited: For niceness and grammar. Also: I do agree that HTML5's additional tags make markup more semantic.
I was referring to the new Parsing/Compatibility rules when it comes to error handling.
|
Australia7069 Posts
Hey lonelypotato do you live in brisbane>?
|
On December 11 2012 19:38 Kiante wrote: Hey lonelypotato do you live in brisbane>?
Nah Adelaide.
|
Thank you for all the answers! I'm sure lonelypotato meant no harm I'll check in later if I have any questions!
|
On December 11 2012 19:08 AmericanUmlaut wrote: How does HTML 5 offer better error handling? HTML is a markup language: it has no error handling.
One of the practical problems with HTML4 was that it did not provide a clear definition of what a user-agent should do when it encountered bad markup.
Ideally this wouldn't be a problem because all markup would be valid, but in the real world "tag soup" is the norm. When a browser encountered something broken like <i><b>hello</i></b>, the behaviour would be undefined. Most browsers would internally convert the above into _some_ kind of valid DOM so the markup could be displayed in the browser, but there as no guarantee that each browser would produce the same DOM.
This would cause problems because CSS and Javascript rely on DOM selectors to function, and if two browsers are producing different internal DOMs for the same (invalid) markup, then that would mean the webpage would display differently in different browsers. A bad thing. You could argue until you were blue in the face that web authors should just fix their markup, but the practical result for the browser vendor was that end-users would complain that their browser "didn't show pages properly" compared to whatever browser the site had been developed for.
Often, browsers would waste a lot of time trying to reverse-engineer what other browsers were doing with bad markup in an effort to remain bug-for-bug compatible and thus display real-world web pages in the same way as their more popular competitors.
HTML5 recognised this problem, and the spec goes to great lengths to define what browsers should do when they encounter bad markup, and especially what they should do while parsing to turn bad markup into good, predictable DOM.
|
On December 11 2012 17:56 Poopi wrote: Thanks for the info guys. I will definitively use it if I ever put something on the internet using PHP/MySQL, however I forgot to precise that it was a school project which I send in .zip and will be tested in local. Thus protecting properly isn't really necessary since well, the only person who will see this will have access to every file anyways.
However we were told about security, but only about mysql_real_escape_string so I did use it even though in this case it's pointless we had to do this at least.
By the way for these type of SQL injects, the "malicious" user (lol) has to know or guess your table names, hasn't he? You should still make it a habit to use parameters anyway. Good habits are half of programming Plus it actually should make the queries more effective.
|
On December 11 2012 20:42 carlfish wrote:Show nested quote +On December 11 2012 19:08 AmericanUmlaut wrote: How does HTML 5 offer better error handling? HTML is a markup language: it has no error handling.
One of the practical problems with HTML4 was that it did not provide a clear definition of what a user-agent should do when it encountered bad markup. Ideally this wouldn't be a problem because all markup would be valid, but in the real world "tag soup" is the norm. When a browser encountered something broken like <i><b>hello</i></b>, the behaviour would be undefined. Most browsers would internally convert the above into _some_ kind of valid DOM so the markup could be displayed in the browser, but there as no guarantee that each browser would produce the same DOM. This would cause problems because CSS and Javascript rely on DOM selectors to function, and if two browsers are producing different internal DOMs for the same (invalid) markup, then that would mean the webpage would display differently in different browsers. A bad thing. You could argue until you were blue in the face that web authors should just fix their markup, but the practical result for the browser vendor was that end-users would complain that their browser "didn't show pages properly" compared to whatever browser the site had been developed for. Often, browsers would waste a lot of time trying to reverse-engineer what other browsers were doing with bad markup in an effort to remain bug-for-bug compatible and thus display real-world web pages in the same way as their more popular competitors. HTML5 recognised this problem, and the spec goes to great lengths to define what browsers should do when they encounter bad markup, and especially what they should do while parsing to turn bad markup into good, predictable DOM. That's true, but it's a user-agent feature, not an aspect of the language itself. It makes the lives of browser developers better, because they don't have to figure out what the de facto industry standard is for being liberal in accepting mangled markup, but it basically has no impact on a developer. It just means that your mangled markup, whether you were trying to write HTML4 or HTML5, will look more consistent across browsers.
|
First of all, thanks again guys! You are a great help 
I would like some practice with my (Not objective or ++!)C loops(for, dowhile, while, and nested loops) before a test my teacher is giving soon. Any sites that are good for this?
Some things my teacher loves to give us is questions that have us: 1) Correct a program and/or rewrite it 2) Find what 1 error is in a program 3) Find what the purpose of the program is (Example is that one she gave us and asked this question just skipped lines...) 4) Write short programs, fulfilling certain credentials. (Example: Write a for loop that displays the factorials of 10)
|
On December 12 2012 06:35 3FFA wrote:First of all, thanks again guys! You are a great help  I would like some practice with my (Not objective or ++!)C loops(for, dowhile, while, and nested loops) before a test my teacher is giving soon. Any sites that are good for this? Some things my teacher loves to give us is questions that have us: 1) Correct a program and/or rewrite it 2) Find what 1 error is in a program 3) Find what the purpose of the program is (Example is that one she gave us and asked this question just skipped lines...) 4) Write short programs, fulfilling certain credentials. (Example: Write a for loop that displays the factorials of 10)
1 and 2 are the same.
I'm just going to point out a common error question, semi-colons after a loop conditional, such as.
int i = 0; for ( i = 0; i < n; i++ ); printf("%d",i);
versus
int i = 0; for ( i = 0; i < n; i++ ) printf("%d",i);
Finding errors should really be fun on tests. Not so in real life.
You will need to differentiate between syntactic and semantic errors.
3. Purpose should be easily found by tracing, if you understand the code. It helps to write out what they're doing by hand. Verify you understand how <= versus < affects a condition.
The output of
int i = 0; while ( i <= 10 ) i = i + 1;
is different from
int i = 0; while ( i < 10 ) i = i + 1;
4. I think you mean factors? There's only 1 factorial of 10. These questions should just require rudimentary math knowledge. Try doing things like the Fibonacci sequence, FizzBuzz, or the 1000 Lockers problem with your computer. (Google)
Practice coding anything. That is literally all the heck you have to do to study a problem solving programming course.
http://www.reddit.com/r/dailyprogrammer/
will help get your started becoming confident in your programming skills. The current day's question tests file input and string comparison among other things. If you don't understand file input, you should understand and use stream redirection.
Otherwise, revisit your old assignment questions and rewrite them with different numbers or input, and make them better using what you know now.
Also, if it's not online, practice coding by hand.
|
Ok thanks! That was better than I was expecting! This forum never fails to surprise me, and this thread never fails to impress me.
|
On December 12 2012 06:49 Blisse wrote:+ Show Spoiler +On December 12 2012 06:35 3FFA wrote:First of all, thanks again guys! You are a great help  I would like some practice with my (Not objective or ++!)C loops(for, dowhile, while, and nested loops) before a test my teacher is giving soon. Any sites that are good for this? Some things my teacher loves to give us is questions that have us: 1) Correct a program and/or rewrite it 2) Find what 1 error is in a program 3) Find what the purpose of the program is (Example is that one she gave us and asked this question just skipped lines...) 4) Write short programs, fulfilling certain credentials. (Example: Write a for loop that displays the factorials of 10) 1 and 2 are the same. I'm just going to point out a common error question, semi-colons after a loop conditional, such as. int i = 0; for ( i = 0; i < n; i++ ); printf("%d",i);
versus int i = 0; for ( i = 0; i < n; i++ ) printf("%d",i);
Finding errors should fun on tests. You need to differentiate between syntactic and semantic errors. 3. Purpose should be easily found by tracing, if you understand the code. It helps to write out stuff by hand. Verify you understand how <= versus < affects a condition. The output of int i = 0; while ( i <= 10 ) i = i + 1;
is different from int i = 0; while ( i < 10 ) i = i + 1;
4. I think you mean factors? There's only 1 factorial of 10. That should just be rudimentary math knowledge. Try doing things like the Fibonacci sequence, FizzBuzz, or the 1000 Lockers problem with your computer. (Google) Practice coding anything. That is literally all the heck you have to do to study a problem solving programming course. http://www.reddit.com/r/dailyprogrammer/will help get your started becoming confident in your programming skills. The current day's question tests file input and string comparison among other things. If you don't understand file input, you should understand and use stream redirection. Otherwise, revisit your old assignment questions and rewrite them with different numbers or input, and make them better using what you know now. Also, if it's not online, practice coding by hand.
Love this specific advice, bolded parts I think are worth stressing (I won't write too much more on this, since Blisse nailed it). No one can tell you the best way for you to study or practice something. There isn't any secret towards practice, except to do something, and to enjoy doing something enough that you want to come back to it later.
It's ok for programming to make you feel frustrated. That's a sign that your brain is actively trying to figure something out, and it may never go away, as the problems you encounter when programming just get larger an more difficult to handle. What you should avoid is feeling bored. If you are feeling bored during studying, then go find a different way to study.
Here's some tunes to study to:
echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6));}" | gcc -x c - && ./a.out | aplay
|
I think he meant 1!, 2!, 3!, ... , 10!
1 2 6 24 etc etc
I'm working through a C++ book and another for writing for embedded systems... lots of fun! Someone on here advised me to purchase "C++ Primer 5th Ed - Lippman, Lajole, Moo" and I'm finding it really handy.. it's much more explanatory than my other books (Programming C, Matlab and Java for Engineers).
One thing I can't really wrap my head around is; why does cin use >> and cout use <<?
I know i can do things like std::cin >> var1 >> var2; but why does cout demand <<? The book says it's because the cin command takes it's right operator as the statement but cout takes it's left hand operand or something along those lines.. confusing
|
Yo guys i need your help!
So, basically lets say we have 2D array, for example height = 7 and width = 7. Next i choose an element in this array, lets say [2][3]. My task is to go to every element that is in horizontal, vertical and diagonal line and do something with it. Now here is my question, is there any other more efficient, less time-consuming way to go through these elements other then making basically 8 loops (one for up, down, left right, up-left, up-right... etc.)?
|
On December 12 2012 09:14 magicmUnky wrote:I think he meant 1!, 2!, 3!, ... , 10! 1 2 6 24 etc etc I'm working through a C++ book and another for writing for embedded systems... lots of fun! Someone on here advised me to purchase "C++ Primer 5th Ed - Lippman, Lajole, Moo" and I'm finding it really handy.. it's much more explanatory than my other books (Programming C, Matlab and Java for Engineers). One thing I can't really wrap my head around is; why does cin use >> and cout use <<? I know i can do things like std::cin >> var1 >> var2; but why does cout demand <<? The book says it's because the cin command takes it's right operator as the statement but cout takes it's left hand operand or something along those lines.. confusing 
Oof, let's start with the lingo. C++ uses these operators as 'stream operators'. The '<<' version is an 'insertion operator'. Putting some bits into a 'stream' can be rather confusing on the low level side of things, so C++ uses this operator with output streams to format the stream to the right, and make a call to sprint(STD_OUT,"**formatted stuff**"), which will push the bits through to the standard out stream (usually your terminal, for embedded projects, its normally the UART0 or SPI port, depending on the board/libraries you are using).
the '>>' operator is used as the 'extraction operator', which then pulls bits off the stream (when they are available) and formats it to fit the right side.
They are both 'overloaded operators' brought in from the <iostream.h> library to make streams easier to use. Overloading an operator just means defining it to use it for a different set of types. For example, you could overload '+' to work for a Vector class (Vector::operator+), then in the definition, make it so when you add two vectors, Vector A and Vector B, it does it the intuitive way.
EDIT: also, cout and cin are referred to as 'streams', which really just means its a file descriptor. Network sockets are streams as well. There are other streams too, but the definition is different system to system.
|
On December 12 2012 09:14 magicmUnky wrote:I know i can do things like std::cin >> var1 >> var2; but why does cout demand <<? The book says it's because the cin command takes it's right operator as the statement but cout takes it's left hand operand or something along those lines.. confusing 
The Idea behind designing it like this was:
cin is a stream, an input stream. a stream flows, with "cin>>var1" ,cin flows into var1.
cout aswell is a stream, with "cout<<var1", var1 flows into the outputstream.
Donnu if that is helpful for remembering when to why use what^^.
|
On December 12 2012 09:19 thOr6136 wrote: Yo guys i need your help!
So, basically lets say we have 2D array, for example height = 7 and width = 7. Next i choose an element in this array, lets say [2][3]. My task is to go to every element that is in horizontal, vertical and diagonal line and do something with it. Now here is my question, is there any other more efficient, less time-consuming way to go through these elements other then making basically 8 loops (one for up, down, left right, up-left, up-right... etc.)?
psuedocode, assuming a square matrix, deal with it:
Given you start at X,Y ---
for(i:0->MATRIX WIDTH) { matrix[Y][i] //horizontal row matrix[i][X] //vertical column matrix[Y+i][X+i] //down and to the right matrix[Y-i][X+i] //up and to the right matrix[Y+i][X-i] //down and to the left matrix[Y-i][X+i] //up and to the left }
Left intentionally unoptimized. This should give you the right idea of how to traverse matrices.
For a bit of math to get you started, you will need a maximum of 2 for loops to do most matrix problems. If you can find no other way, traverse the entire matrix, and check if the spot you are at is the one you are looking for using your math equations you calculated:
for(i:0->MAX_X) for(j:0->MAX_Y) if(j==Y) //horizontal row if(X+i==Y+j) //diagonal and so on..
The single for loop example above is a reduction of this complete case
|
On December 12 2012 06:49 Blisse wrote:Show nested quote +On December 12 2012 06:35 3FFA wrote:First of all, thanks again guys! You are a great help  I would like some practice with my (Not objective or ++!)C loops(for, dowhile, while, and nested loops) before a test my teacher is giving soon. Any sites that are good for this? 4) Write short programs, fulfilling certain credentials. (Example: Write a for loop that displays the factorials of 10) 4. I think you mean factors? There's only 1 factorial of 10. These questions should just require rudimentary math knowledge. Try doing things like the Fibonacci sequence, FizzBuzz, or the 1000 Lockers problem with your computer. (Google) Practice coding anything. That is literally all the heck you have to do to study a problem solving programming course. http://www.reddit.com/r/dailyprogrammer/will help get your started becoming confident in your programming skills. The current day's question tests file input and string comparison among other things. If you don't understand file input, you should understand and use stream redirection. Otherwise, revisit your old assignment questions and rewrite them with different numbers or input, and make them better using what you know now. Also, if it's not online, practice coding by hand.
http://projecteuler.net/ is great for those relatively quick, self contained programming problems.
Some are really tricky and may take a little while but they're all perfectly doable by 1 person at a reasonable pace, try doing one or two a week and you'll really improve. It's also a good way to learn new languages, trying to redo old problems in a new language can help you get a grip on it a bit better.
|
On December 12 2012 18:31 adwodon wrote:Show nested quote +On December 12 2012 06:49 Blisse wrote:On December 12 2012 06:35 3FFA wrote:First of all, thanks again guys! You are a great help  I would like some practice with my (Not objective or ++!)C loops(for, dowhile, while, and nested loops) before a test my teacher is giving soon. Any sites that are good for this? 4) Write short programs, fulfilling certain credentials. (Example: Write a for loop that displays the factorials of 10) 4. I think you mean factors? There's only 1 factorial of 10. These questions should just require rudimentary math knowledge. Try doing things like the Fibonacci sequence, FizzBuzz, or the 1000 Lockers problem with your computer. (Google) Practice coding anything. That is literally all the heck you have to do to study a problem solving programming course. http://www.reddit.com/r/dailyprogrammer/will help get your started becoming confident in your programming skills. The current day's question tests file input and string comparison among other things. If you don't understand file input, you should understand and use stream redirection. Otherwise, revisit your old assignment questions and rewrite them with different numbers or input, and make them better using what you know now. Also, if it's not online, practice coding by hand. http://projecteuler.net/ is great for those relatively quick, self contained programming problems. Some are really tricky and may take a little while but they're all perfectly doable by 1 person at a reasonable pace, try doing one or two a week and you'll really improve. It's also a good way to learn new languages, trying to redo old problems in a new language can help you get a grip on it a bit better.
I'm less a fan of Project Euler because it only focuses on mathematical problem solving. DailyProgrammer puts out a mix of mathematical problem solving, and also other stuff like string manipulation and fun things like Pokemon type comparisons, which can involve a lot more than just hard coding some numbers together.
On December 12 2012 09:14 magicmUnky wrote:I think he meant 1!, 2!, 3!, ... , 10! 1 2 6 24 etc etc I'm working through a C++ book and another for writing for embedded systems... lots of fun! Someone on here advised me to purchase "C++ Primer 5th Ed - Lippman, Lajole, Moo" and I'm finding it really handy.. it's much more explanatory than my other books (Programming C, Matlab and Java for Engineers). One thing I can't really wrap my head around is; why does cin use >> and cout use <<? I know i can do things like std::cin >> var1 >> var2; but why does cout demand <<? The book says it's because the cin command takes it's right operator as the statement but cout takes it's left hand operand or something along those lines.. confusing 
>> is an extraction operator. http://www.cplusplus.com/reference/istream/istream/operator>>/
<< is an insertion operator. http://www.cplusplus.com/reference/ostream/ostream/operator<</
What does that mean?
When you do,
std::cin >> var;
you are performing an extraction out of the std::cin stream, which is your standard input.
When you do,
std::cout << word << std::endl;
you are performing an insertion of your word into the std::cout stream, which is your standard output.
Why don't they combine the two? Because overloading functions like you want would confuse meaning of the words. It is much more clear to see in the
std::cin >> var; std::cout << word << std::endl;
case, that the values from the stream std::cin are extracted into the value var, and the word is being inserted into the stream std::cout.
var << std::cin; std::cout << var;
would look very strange, because now it's not clear what you're doing exactly. You overload the meaning of << as both an insertion operation and an extraction operation. However, it doesn't make sense to do that because the two operations are not associative. The + operator is associative in the sense that 1 + 2 == 2 + 1. It's an operation of add regardless. However, std::cin << word != word << std::cin, because they're both not insertion operations.
The << and >> separate the meaning of insertion and extraction.
I hope that makes some sense. I didn't design the language, but this is what seems to make sense for me.
|
|
|
|