-
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.
Merge pull request #9 from sebas119/sebastian_lopez
Unsigned data types for printf
- Loading branch information
Showing
5 changed files
with
122 additions
and
1 deletion.
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
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
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
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
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,79 @@ | ||
#include "holberton.h" | ||
|
||
/** | ||
* printUnsignedDecimal - Prints an unsigned int | ||
* @args: Argument passed | ||
* | ||
* Return: length of data | ||
*/ | ||
int printUnsignedDecimal(va_list args) | ||
{ | ||
char buff[40]; | ||
char *str; | ||
unsigned int num = va_arg(args, unsigned int); | ||
int size; | ||
|
||
str = unsigned_itoa(num, buff, 10); | ||
size = _strlen(str); | ||
|
||
return (write(1, str, size)); | ||
} | ||
|
||
/** | ||
* printUnsignedOctal - Prints an unsigned octal | ||
* @args: Argument passed | ||
* | ||
* Return: length of data | ||
*/ | ||
int printUnsignedOctal(va_list args) | ||
{ | ||
char buff[40]; | ||
char *str; | ||
int num = va_arg(args, int); | ||
int size; | ||
|
||
str = unsigned_itoa(num, buff, 8); | ||
size = _strlen(str); | ||
|
||
return (write(1, str, size)); | ||
} | ||
|
||
|
||
|
||
/** | ||
* printUnsignedHex - Prints an unsigned hex | ||
* @args: Argument passed | ||
* | ||
* Return: length of data | ||
*/ | ||
int printUnsignedHex(va_list args) | ||
{ | ||
char buff[40]; | ||
char *str; | ||
int num = va_arg(args, int); | ||
int size; | ||
|
||
str = unsigned_itoa(num, buff, 16); | ||
size = _strlen(str); | ||
|
||
return (write(1, str, size)); | ||
} | ||
|
||
/** | ||
* printUnsignedHexUpper - Prints an unsigned hex upper | ||
* @args: Argument passed | ||
* | ||
* Return: length of data | ||
*/ | ||
int printUnsignedHexUpper(va_list args) | ||
{ | ||
char buff[33]; | ||
char *str; | ||
int num = va_arg(args, int); | ||
int size; | ||
|
||
str = string_toupper(unsigned_itoa(num, buff, 16)); | ||
size = _strlen(str); | ||
|
||
return (write(1, str, size)); | ||
} |