-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_b.c
71 lines (64 loc) · 1.14 KB
/
print_b.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "crikey.h"
/**
* id_print - prints percent i and percent d
* @n: the integer to print
*
* Return: integer
*/
void id_print(int n)
{
unsigned int m;
if (n < 0)
{
_putchar('-');
m = -n;
}
else
m = n;
if (m / 10)
{
id_print(m / 10);
}
_putchar(m % 10 + '0');
}
/**
* printExitStatus - prints the exit status to the user
* @tally: the tally number
* @exitStatus: exit status of the child
*
* Return: no return
*/
void printExitStatus(int tally, int exitStatus)
{
_print("lightning: ");
id_print(tally);
_print(": ");
id_print(exitStatus);
_print(": not found\n");
}
/**
* printComNotFound - prints the exit status to the user
* @tally: the tally number
* @command: exit status of the child
*
* Return: no return
*/
void printComNotFound(int tally, char *command)
{
_print("lightning: ");
id_print(tally);
_print(": ");
_print(command);
_print(": not found\n");
}
/**
* _putchar - writes the character c to stdout
* @c: The character to print
*
* Return: On success 1.
* On error, -1 is returned, and errno is set appropriately.
*/
int _putchar(char c)
{
return (write(1, &c, 1)); /* writes to stdio */
}