| Blockland Forums > General Discussion |
| print "Hello World!" |
| << < (11/16) > >> |
| lolz??:
--- Quote from: Pacnet on February 25, 2014, 10:09:29 PM ---1: There's no semicolon on line 5 2: You should not return 42 for main(), a common practice is to return 0 3: Iostream (std::cout << x) is better than printf EDIT: Sorry. I just had to... --- End quote --- look at me guys im a great programmer |
| $trinick:
--- Quote from: Blockzillahead on February 26, 2014, 03:07:32 PM ---it automatically knows what youre printing with printf you have to define if its a float, string or integer ect + i think its easier to overload it --- End quote --- You don't have to define if it's a float, string, or integer with printf. int num = 5; printf(num); will print "5". Printf also doesn't use a buffer, so you can't overflow the function any more than you can overflow cout. I assume you mean overflow, because an overload is something entirely irrelevant to printing anything. |
| Blockzillahead:
--- Quote from: $trinick on February 26, 2014, 07:15:21 PM ---You don't have to define if it's a float, string, or integer with printf. int num = 5; printf(num); will print "5". Printf also doesn't use a buffer, so you can't overflow the function any more than you can overflow cout. I assume you mean overflow, because an overload is something entirely irrelevant to printing anything. --- End quote --- overloading the operators >> or << and changing the way they print certain variables also i was referring to --- Code: ---int number = 12; printf("%f", number); //gives a value of 'nan' std::cout << number; --- End code --- cout knows the variable number is an integer, printf will not know how to do that unless you define it, the automatic process from cout stops you from making silly mistakes like above also if you do just printf(number) you get an error saying 'cannot convert "int" to "const char*"' i guess its more of a personal preference but i see more benefits to cout |
| Subpixel:
ok guys this has gone too far --- Code: ---exit; --- End code --- |
| nixton:
--- Quote from: LegoFish on February 25, 2014, 10:06:35 PM ---I'm not an alternate account, but I'll be aware. --- End quote --- Oh shiz, he's "Aware"'s alt! Loljk have fun! |
| Navigation |
| Message Index |
| Next page |
| Previous page |