-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
420d322
commit acdb696
Showing
10 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |