Skip to content

Instantly share code, notes, and snippets.

@Shameera17
Forked from ramsey/hello1.c
Created November 11, 2018 04:51
Show Gist options
  • Save Shameera17/118d6e13fb849ab5668d0ea4068f38fe to your computer and use it in GitHub Desktop.
Save Shameera17/118d6e13fb849ab5668d0ea4068f38fe to your computer and use it in GitHub Desktop.
Hello, World in C
#include <stdio.h>
int main()
{
printf("hello, world\n");
}
// Compile, then run `./a.out 1>stdout.txt 2>stderr.txt`
// Then run `echo $?`
// stdout.txt should contain "hello, world"
// stderr.txt should be empty
// Your `echo $?` command should return 0
#include <stdio.h>
int main()
{
printf("hello, world\n");
return 1;
}
// Compile, then run `./a.out 1>stdout.txt 2>stderr.txt`
// Then run `echo $?`
// stdout.txt should contain "hello, world"
// stderr.txt should be empty
// Your `echo $?` command should return 1
#include <stdio.h>
int main()
{
fprintf(stdout, "hello, world\n");
fprintf(stderr, "this is an error\n");
return 1;
}
// Compile, then run `./a.out 1>stdout.txt 2>stderr.txt`
// Then run `echo $?`
// stdout.txt should contain "hello, world"
// stderr.txt should contain "this is an error"
// Your `echo $?` command should return 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment