Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Low_level_programming

Low_level_programming/000-hello_world Part 1

What happens when you type gcc main.c What is an entry point What is main How to print text using printf, puts and putchar

000-hello_world

Learning Objectives

  • What happens when you type gcc main.c
  • What is an entry point
  • What is main
  • How to print text using printfputs and putchar
  • How to get the size of a specific type using the unary operator sizeof
  • How to compile using gcc
  • What is the default program name when compiling with gcc
  • What is the official C coding style and how to check your code with betty-style
  • How to find the right header to include in your source code when using a standard library function
  • How does the main function influence the return value of the program

Solutions

0-preprocessor

#!/bin/bash
gcc -o c $CFILE -E

1-compiler

#!/bin/bash
gcc -c $CFILE

2-assembler

#!/bin/bash
gcc -S $CFILE

3-name

#!/bin/bash
gcc -o cisfun $CFILE

4-puts.c

#include <stdio.h>

/**
 * main - Entry point
 *
 * Return: Always 0 (Success)
 */
int main(void)
{
	puts("\"Programming is like building a multilingual puzzle");
	return (0);
}

5-printf.c

#include <stdio.h>

/**
 * main - Entry point
 *
 * Return: Always 0 (Success)
 */
int main(void)
{
	printf("with proper grammar, but the outcome is a piece of art,\n");
	return (0);
}

6-size.c

#include <stdio.h>

/**
 * main - Entry point
 *
 * Return: Always 0 (Success)
 */
int main(void)
{
	int a;
	long int b;
	long long int c;
	char d;
	float f;

	printf("Size of a char: %lu byte(s)\n", (unsigned long)sizeof(d));
	printf("Size of an int: %lu byte(s)\n", (unsigned long)sizeof(a));
	printf("Size of a long int: %lu byte(s)\n", (unsigned long)sizeof(b));
	printf("Size of a long long int: %lu byte(s)\n", (unsigned long)sizeof(c));
	printf("Size of a float: %lu byte(s)\n", (unsigned long)sizeof(f));
	return (0);
}

README.md

To create a readme.md file just

echo ‘repo description here’ > README.md

If you have any questions please leave it on the comment box bellow.

#Complete the advance task here > https://scisiz.com/low_level_programming-part-2/

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
system_engineering-devops

system_engineering-devops/0x01-shell_permissions Part 1

Next Post
Low_level_programming

Low_level_programming/000-hello_world Part 1

Please Leave a comment on comment section, let me know what you think about this article.

Related Posts
Low_level_programming

alxlow_level_programming/0x02-functions_nested_loops/

Table of Contents Hide 0x02-functions_nested_loopsRequirements_putchar.c main.h0-putchar.c1-alphabet.c 2-print_alphabet_x10.c 3-islower.c 4-isalpha.c 5-sign.c6-abs.c7-print_last_digit.c8-24_hours.c9-times_table.c10-add.c 11-print_to_98.c100-times_table.c 101-natural.c102-fibonacci.c 103-fibonacci.c104-fibonacci.c README.md 0x02-functions_nested_loops Requirements Allowed editors: vi, vim, emacs…
Read More
Hey, if you have any questions and want to talk to one of our specialists chat up here:
Chat me up