Code:#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
}
Printable View
Code:#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
}
:confused:Code:#include <iostream>
int main()
{
cout << "Hello World!";
}
???
I've only ever used C++ years ago, I've never known it well by any means. But I never used std::.
I can't remember for sure, but isn't something else included at the top, presumably so you don't always can to type std::
That isn't more efficient :mad:Quote:
Originally posted by mendhak
:confused:Code:#include <iostream>
int main()
{
cout << "Hello World!";
}
???
endl flushes teh buffer. Also, you didn't use std:: or using namespace so your code won't compile
std:: is better than using namespace std;. This way, I can have functions named cout and other stuff named the same as what std has.Quote:
Originally posted by Acidic
I've only ever used C++ years ago, I've never known it well by any means. But I never used std::.
I can't remember for sure, but isn't something else included at the top, presumably so you don't always can to type std::
I do not think you need to type that, it should work without that thing. std stands for standard output .....
Um no, std is the namespace in whcih the functions are in. If you used a deprecate header like <iostream.h> then you don't need it, but with the new header style <iostream> you do.Quote:
Originally posted by spoiledkid
I do not think you need to type that, it should work without that thing. std stands for standard output .....
If you try to compile without using std and the new header style, the compiler will have no clue where the function cout and endl are located
Write it in C :DQuote:
Originally posted by kasracer
Code:#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
}
Code:#include <stdio.h>
int main(void)
{
puts ("Hello World");
return 0;
}
Why would you want it more efficient?
If you really want, you can write it directly to the buffer, but...
here you go :D
More efficient AND managed code!
Code:using System;
class Class1
{
public static void Main()
{
Console.WriteLine("HELLO WORLD");
}
}
USE NAME SPACE STD DAMN MEnDHAK :)
Code:#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
}
Managed code is never more efficient.
C# might be shorter, but this code isn't.
Sorry, I don't know asm :bigyello:
This thread was a joke to break the forum in. However, how exactly would you write directly to the buffer?Quote:
Originally posted by CornedBee
Why would you want it more efficient?
If you really want, you can write it directly to the buffer, but...
Eww hell naws. Mine will atleast compile on linux :DQuote:
Originally posted by Memnoch1207
here you go :D
More efficient AND managed code!
Code:using System;
class Class1
{
public static void Main()
{
Console.WriteLine("HELLO WORLD");
}
}
QBasic:
VB Code:
Print "HELLO WORLD!"
It doesn't get much shorter than that.
mono ;)Quote:
Originally posted by kasracer
Mine will atleast compile on linux :D
You can access the stream buffer using the rdbuf member function. Then you can use its functions to write directly, avoiding all the formatting and checking stuff that the ostreams do.
That would make it less efficient though.Quote:
Originally posted by alkatran
QBasic:
VB Code:
Print "HELLO WORLD!"
It doesn't get much shorter than that.
I'll give it a try...
i think this would be the code for assembly.Code:#include<iostream.h>
int main()
{
cout << "Hello World!\n";
return 0;
}
Code:.model SMALL
.stack 64
.data
msg DB "Hello World!", 0Ah, 0Dh, '$'
.code
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AH, 09H
LEA DX, msg
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
DOS assembly...
Please include the language in all subject lines in this forum.
using just the necessary cout code instead of the entire header
also maybe feeding the ascii values instead of a string would be faster
no way im gonna look it up tho..
The "necessary" cout code is quite a lot: The complete definitions of basic_ostream, basic_ios, ios_base, basic_ostreambuf and a few other minor things.
And feeding ASCII values makes no difference.
y is this? are they converted when compiling the prog?Quote:
Originally posted by CornedBee
And feeding ASCII values makes no difference.
Why do you think feeding it ascii values would speed it up? A string is made up of ascii values.....Quote:
Originally posted by dis1411
y is this? are they converted when compiling the prog?
b/c SOMETHING has to convert the letters to their respective ascii values
is this case youre the one who's doing it, not the computer
however, if the compiler converts them for u, it wouldnt make a difference when the program is run
Actually the operating system converts the scan codes from your keyboards to the ASCII values that your text editor inserts into the program source code. It's the text editor (or the OS) that has to convert the ASCII codes to the character glyphs so you can see them.
So many people, even among programmers, simply don't know or realize that there is no difference to a computer between characters and their ASCII codes except in usage - and that is up to the programmer to decide. To the computer, it's all just numbers.
Ok,as far as topic asm is the most effeciant. What I really wanted to say though is is it just me or is MartinLess well more of of a dork then a programmer has a right to be. No offence Martin but was it nessecary to talk about the topic title and what if I want to use [ c o d e ] and [ / c o d e] tags because I'm posting non VB code?
I wish I had my asm code resources I can put out Hello World out in three lines of asm if I remember right..
Well if you are going to offend me at least spell my name right :) Anyhow I mentioned the topic title because if you had read Acidic's sticky you would see that he is requesting that people do that and it's my job as a moderator to remind people of those things.Quote:
Originally posted by Magiaus
...What I really wanted to say though is is it just me or is MartinLess well more of of a dork then a programmer has a right to be. No offence Martin but was it nessecary to talk about the topic title and what if I want to use [ c o d e ] and [ / c o d e] tags because I'm posting non VB code?....
I don't understand what you mean about using [code][/code] tags.
I always think that when I read your signiture and I was trying to rib you, but I failed :cool: