forked from sanjurosaves/printf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorefunctions.c
More file actions
61 lines (56 loc) · 962 Bytes
/
Copy pathmorefunctions.c
File metadata and controls
61 lines (56 loc) · 962 Bytes
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
#include "holberton.h"
/**
* printchar - writes the character c to stdout
* @c: The character to print
*
* Return: Count of all printchars in this program.
*/
int printchar(char c)
{
return (write(1, &c, 1));
}
/**
* _strlen - calculates no of chars in a string
* @str: pointer to the string
* Return: length of the string
*/
int _strlen(char *str)
{
int i = 0;
while (str[i] != '\0')
{
i++;
}
return (i);
}
/**
* handlebackslash - checking the next position after backslash
* @format: pointer to the string
* @place: position
* @len: calculating the lenght
* Return: length of the string
*/
int handlebackslash(const char *format, int place, int len)
{
if (format[place + 1] == 92)
{
printchar(92);
len++;
}
else if (format[place + 1] == 34)
{
printchar(34);
len++;
}
else if (format[place + 1] == 39)
{
printchar(39);
len++;
}
else if (format[place + 1] == 37)
{
printchar(37);
len++;
}
return (len);
}