-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added unit tests for printf %x format modifier * slightly modified %d format specifier test case to cover precision format specifier * modified handling of %d specifer to handle precision, added propert handling of %x format specifier * adjusted spacing * changed the flawed merge of Train's fix * fixed handling of octal print specifier * fixed handling of octal print specifier * added a test case for unsigned printf format specifiers * added printf format specifier handling for unsigned * refactored the common code for width and precision specifiers; added handling for 0 value / 0 precision * fixed default precision semantics for d,i,x,X,o,u * fixed a bug due to an evaluation order * fixed code alignment
- Loading branch information
Showing
5 changed files
with
157 additions
and
19 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
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,16 @@ | ||
#include <stdio.h> | ||
|
||
|
||
int main() { | ||
printf("------------------------\n"); | ||
unsigned int c = 12; | ||
printf("Hex 0: |%.x|\n", (unsigned)0); | ||
printf("Hex 1: |%x|\n", c); | ||
printf("Hex 2: |%0x|\n", c); | ||
printf("Hex 3: |%02x|\n", c); | ||
printf("Hex 3: |%-2x|\n", c); | ||
printf("Hex 4: |%15x|\n", c); | ||
printf("Hex 5: |%15.4x|\n", c); | ||
printf("Hex 6: |%015x|\n", c); | ||
printf("------------------------\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,16 @@ | ||
#include <stdio.h> | ||
|
||
|
||
int main() { | ||
printf("------------------------\n"); | ||
int c = 42; | ||
printf("Oct 1: |%.o|\n", 0); | ||
printf("Oct 1: |%o|\n", c); | ||
printf("Oct 2: |%0o|\n", c); | ||
printf("Oct 4: |%-2o|\n", c); | ||
printf("Oct 3: |%08o|\n", c); | ||
printf("Oct 5: |%15o|\n", c); | ||
printf("Oct 6: |%15.4o|\n", c); | ||
printf("Oct 7: |%015o|\n", c); | ||
printf("------------------------\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,18 @@ | ||
#include <stdio.h> | ||
|
||
|
||
int main() { | ||
printf("------------------------\n"); | ||
unsigned int c = 7; | ||
printf("Unsigned 1: |%.u|\n", (unsigned)42); | ||
printf("Unsigned 2: |%u|\n", c); | ||
printf("Unsigned 3: |%0u|\n", c); | ||
printf("Unsigned 4: |%04u|\n", c); | ||
printf("Unsigned 5: |%-4u|\n", c); | ||
printf("Unsigned 6: |%15u|\n", c); | ||
printf("Unsigned 7: |%15.4u|\n", c); | ||
printf("Unsigned 8: |%015u|\n", c); | ||
printf("Unsigned 9: |%15.0u|\n", (unsigned)0); | ||
printf("Unsigned 9: |%15.2u|\n", (unsigned)0); | ||
printf("------------------------\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