Skip to content

Commit

Permalink
main done
Browse files Browse the repository at this point in the history
  • Loading branch information
EphraimTM299 committed Dec 21, 2022
1 parent 420d322 commit acdb696
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 0 deletions.
30 changes: 30 additions & 0 deletions 0x05-pointers_arrays_strings/100-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "main.h"
#include <stdio.h>

/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
int nb;

nb = _atoi("98");
printf("%d\n", nb);
nb = _atoi("-402");
printf("%d\n", nb);
nb = _atoi(" ------++++++-----+++++--98");
printf("%d\n", nb);
nb = _atoi("214748364");
printf("%d\n", nb);
nb = _atoi("0");
printf("%d\n", nb);
nb = _atoi("Suite 402");
printf("%d\n", nb);
nb = _atoi(" + + - -98 Battery Street; San Francisco, CA 94111 - USA ");
printf("%d\n", nb);
nb = _atoi("---++++ -++ Sui - te - 402 #cisfun :)");
printf("%d\n", nb);
return (0);
}
15 changes: 15 additions & 0 deletions 0x05-pointers_arrays_strings/4-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "main.h"

/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
char *str;

str = "I do not fear computers. I fear the lack of them - Isaac Asimov";
print_rev(str);
return (0);
}
21 changes: 21 additions & 0 deletions 0x05-pointers_arrays_strings/4-print_rev.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "main.h"

/**
* print_rev - printing a string in reverse
* @s: the string to be printed in rev
*/

void print_rev(char *s)
{
int i, n;

n = 0;
while (s[n] != '\0')
n++;

for (i = n - 1; i >= 0; i--)
{
_putchar(s[i]);
}
_putchar('\n');
}
17 changes: 17 additions & 0 deletions 0x05-pointers_arrays_strings/5-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "main.h"
#include <stdio.h>

/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
char s[10] = "My School";

printf("%s\n", s);
rev_string(s);
printf("%s\n", s);
return (0);
}
26 changes: 26 additions & 0 deletions 0x05-pointers_arrays_strings/5-rev_string.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "main.h"
/**
* rev_string - reverses a string
* _putchar - print each character
* @s: char to check
*
* Description: This will reverse a string
* Return: 0 is success
*/
void rev_string(char *s)
{
int a = 0, b, c;
char d;

while (s[a] != '\0')
{
a++;
}
c = a - 1;
for (b = 0; c >= 0 && b < c; c--, b++)
{
d = s[b];
s[b] = s[c];
s[c] = d;
}
}
15 changes: 15 additions & 0 deletions 0x05-pointers_arrays_strings/6-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "main.h"

/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
char *str;

str = "0123456789";
puts2(str);
return (0);
}
17 changes: 17 additions & 0 deletions 0x05-pointers_arrays_strings/6-puts2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "main.h"
/**
* puts2 - prints every other character of a string
*
* @str: char to check
*
* Return: 0 when successful
*/
void puts2(char *str)
{
int string;

for (string = 0; str[string] != '\0'; string++)
if (string % 2 == 0)
_putchar(str[string]);
_putchar('\n');
}
15 changes: 15 additions & 0 deletions 0x05-pointers_arrays_strings/7-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "main.h"

/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
char *str;

str = "0123456789";
puts_half(str);
return (0);
}
19 changes: 19 additions & 0 deletions 0x05-pointers_arrays_strings/8-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "main.h"

/**
* main - check the code for
*
* Return: Always 0.
*/
int main(void)
{
int array[5];

array[0] = 98;
array[1] = 402;
array[2] = -198;
array[3] = 298;
array[4] = -1024;
print_array(array, 5);
return (0);
}
18 changes: 18 additions & 0 deletions 0x05-pointers_arrays_strings/9-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "main.h"
#include <stdio.h>

/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
char s1[98];
char *ptr;

ptr = _strcpy(s1, "First, solve the problem. Then, write the code\n");
printf("%s", s1);
printf("%s", ptr);
return (0);
}

0 comments on commit acdb696

Please sign in to comment.