aboutsummaryrefslogtreecommitdiffstats
path: root/cap.c
diff options
context:
space:
mode:
Diffstat (limited to 'cap.c')
-rw-r--r--cap.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/cap.c b/cap.c
index c36732d..d87339f 100644
--- a/cap.c
+++ b/cap.c
@@ -12,11 +12,10 @@
#include <stdbool.h>
#include <ctype.h>
-char *capitalise(char *string)
+char *capitalise(char *string, size_t size)
{
- size_t length = strlen(string);
bool last_sep = true; /* Nothing is a separator too. */
- for (unsigned i = 0; i < length; i++) {
+ for (size_t i = 0; i < size; i++) {
if (isalpha(string[i])) {
string[i] = last_sep ? toupper(string[i]) : tolower(string[i]);
last_sep = false;
@@ -28,7 +27,7 @@ char *capitalise(char *string)
int main(void)
{
- char string[] = "thIs iS MEANT to Be some Kind OF tEsT strinG?\n";
- printf(capitalise(string));
- return true;
+ char string[] = "thIs iS MEANT to Be some Kind OF tEsT strinG?!.-+=#'; +-'#~@\n";
+ printf("%s", capitalise(string, strlen(string)));
+ return 0;
}