mirror of
https://github.com/RustyRaptor/ProgrammingLanguages.git
synced 2026-12-03 21:55:15 -07:00
Added comments
This commit is contained in:
1 parent
e601affb57
commit
324363b7e9
2 files changed
+43
-5
No files matched your search
+25
-4
@@ -1,12 +1,26 @@
|
||||
/*
|
||||
Ziad Arafat
|
||||
Febuary 1 2023
|
||||
Input: None
|
||||
Output: Prints my name to the stdout
|
||||
preconditions: None
|
||||
postconditions: My name will be printed on the stdout
|
||||
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
/*
|
||||
Main function will call my_name_array() and cast it's integer array to a char
|
||||
array and pass that to a printf() so it displays the string.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
|
||||
// cast the returned array to a char pointer and pass it to printf
|
||||
printf((char *)my_name_array());
|
||||
|
||||
|
||||
printf("\n"); // print a new line
|
||||
|
||||
|
||||
@@ -16,13 +30,20 @@ int main()
|
||||
/*
|
||||
Generate my name as a int array.
|
||||
Each int will store 4 chars in little endian form.
|
||||
|
||||
PRE: None
|
||||
POST: Return will be an integer pointer to a new array containing the correct bytes
|
||||
to represent Ziad Arafat in ascii and stored in Little Endian format.
|
||||
|
||||
Returns: Integer pointer to a new array containing the correct bytes
|
||||
to represent Ziad Arafat in ascii and stored in Little Endian format.
|
||||
*/
|
||||
int* my_name_array() {
|
||||
int *name_arr = (int *)malloc(11);
|
||||
|
||||
name_arr[0] = 0x6461695a; // Z,I,A,D -> D,A,I,Z
|
||||
name_arr[1] = 0x61724120; // ,A,R,A -> A,R,A,
|
||||
name_arr[2] = 0x746166; // F,A,T -> T,A,F
|
||||
name_arr[0] = 0x6461695a; // Z,i,a,d -> d,a,i,Z
|
||||
name_arr[1] = 0x61724120; // ,A,r,a -> a,r,A,
|
||||
name_arr[2] = 0x746166; // f,a,t -> t,a,f
|
||||
name_arr[3] = 0; // END String
|
||||
|
||||
return name_arr;
|
||||
|
||||
+18
-1
@@ -1,7 +1,24 @@
|
||||
/*
|
||||
Ziad Arafat
|
||||
Febuary 1 2023
|
||||
Input: None
|
||||
Output: Prints my name to the stdout
|
||||
preconditions: None
|
||||
postconditions: My name will be printed on the stdout
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
Creates an array with my name in it as ascii numbers in little endian format
|
||||
Generate my name as a int array.
|
||||
Each int will store 4 chars in little endian form.
|
||||
|
||||
PRE: None
|
||||
POST: Return will be an integer pointer to a new array containing the correct bytes
|
||||
to represent Ziad Arafat in ascii and stored in Little Endian format.
|
||||
|
||||
Returns: Integer pointer to a new array containing the correct bytes
|
||||
to represent Ziad Arafat in ascii and stored in Little Endian format.
|
||||
*/
|
||||
int* my_name_array();
|
||||
Reference in new issue
Block a user