-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.c
More file actions
43 lines (42 loc) · 804 Bytes
/
strings.c
File metadata and controls
43 lines (42 loc) · 804 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
#include "main.h"
/**
* printBuffer - prints buffer contents
* @buffer: array for buffer.
* @bufferIndex: index
*
*/
void printBuffer(char buffer[], int *bufferIndex)
{
int i = 0;
if (*bufferIndex > 0)
{
while( i < *bufferIndex)
{
printCharacter(buffer[i]);
i++;
}
}
*bufferIndex = 0;
}
/**
* printSpecialString - prints special string
* @str: input
*/
void printSpecialString(const char *str)
{
int i= 0;
while ( str[i] != '\0')
{
if (str[i] < ' ' || str[i] >= 127)
{
printCharacter('\\');
printCharacter('x');
printUnsigned((unsigned char)str[i], 16, 1, 0, 0);
}
else
{
printCharacter(str[i]);
}
i++;
}
}