Content deleted Content added
m Archiving 1 discussion(s) from Talk:C (programming language)) (bot |
m Archiving 1 discussion(s) from Talk:C (programming language)) (bot |
||
Line 64:
* [[commons:File:Hello World Brian Kernighan 1974.jpg|Hello World Brian Kernighan 1974.jpg]]<!-- COMMONSBOT: discussion | 2020-10-19T14:18:17.839945 | Hello World Brian Kernighan 1974.jpg -->
Participate in the deletion discussion at the [[commons:Commons:Deletion requests/File:Hello World Brian Kernighan 1974.jpg|nomination page]]. —[[User:Community Tech bot|Community Tech bot]] ([[User talk:Community Tech bot|talk]]) 14:18, 19 October 2020 (UTC)
== About the Hello World Example ==
I think that the hello world example should be like this:
<syntaxhighlight lang="cpp">
#include <stdio.h>
int main(){
printf("%s\n""Hello World!");
return 0;
}
</syntaxhighlight>
<small><span class="autosigned">—[[User:ThesenatorO5-2|ThesenatorO5-2]] ([[User talk:ThesenatorO5-2|talk]] • [[Special:Contributions/ThesenatorO5-2|contribs]]) 09:38, 25 June 2020 (UTC)</span></small><!-- Template:Signing-->
:That's incorrect too and will most likely result in a runtime crash. <!-- Template:Unsigned --><small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:Brett Alexander Hunter|Brett Alexander Hunter]] ([[User talk:Brett Alexander Hunter#top|talk]] • [[Special:Contributions/Brett Alexander Hunter|contribs]]) </small>
:* '''Hello world''' are examples of minimal standard-compliant code that perform the specific task of printing a message on the device's display/output. The code currently on the article is correct and requires no additional complications. [[User:Fbergo|Fbergo]] ([[User talk:Fbergo|talk]]) 15:53, 25 June 2020 (UTC)
As things stand right now, your second example will result in a compiler warning, won't it? You specifically indicate an 'int' return value but return nothing. That's anything but 'standard-conforming' as you call it.
Brian was brilliant at educating in that book. The way he told you something but also left off tidbits and crumbs for the lesson coming up.
The actual purpose of hello world is to get your environment up and running.
Cheers. <!-- Template:Unsigned --><small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:Brett Alexander Hunter|Brett Alexander Hunter]] ([[User talk:Brett Alexander Hunter#top|talk]] • [[Special:Contributions/Brett Alexander Hunter|contribs]]) </small>
It should be like this.
<syntaxhighlight lang="cpp">
#include <stdio.h>
int main(){
printf("%s\n", "Hello World!"); // Note that the two args should have a , between.
return 0;
}
</syntaxhighlight>01:05, 19 August 2020 (UTC)[[User:ThesenatorO5-2|ThesenatorO5-2]]<sup>[[User_talk:ThesenatorO5-2|argue with me]]</sup>
:Nah, we should stick to the minimal version. There is no reason to break the string into two arguments. - [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 01:14, 19 August 2020 (UTC)
In ''The ANSI C Programming Language'' book by the inventors of C Brian Kernighan and Dennis Ritchie, the example they used was as follows:
<syntaxhighlight lang="cpp">
#include <stdio.h>
main()
{
printf("hello, world\n");
}
</syntaxhighlight>
Although I must say that in order to get that to compile I had to make it "int main()" rather than just main. [[User:Thunderblood101|Thunderblood101]] ([[User talk:Thunderblood101|talk]]) 21:12, 17 January 2021 (UTC)
: Even <code>int main(void)</code>, and with <code>return 0;</code> at the end. — [[User:Vincent Lefèvre|Vincent Lefèvre]] ([[User talk:Vincent Lefèvre|talk]]) 21:27, 17 January 2021 (UTC)
|