aboutsummaryrefslogtreecommitdiffstats
path: root/cap.c
diff options
context:
space:
mode:
authorEliteTK <tomasz.kramkowski@gmail.com>2014-12-29 01:30:17 +0000
committerEliteTK <tomasz.kramkowski@gmail.com>2014-12-29 01:30:17 +0000
commitecdc45374aecdbcdb5c1d374742d9c528fb8298e (patch)
tree850edf5e8fd9d9d6bf6cfbf913706fb27e876321 /cap.c
parent7636b3f77215cc422b7dbf1d636269bea4b01726 (diff)
downloadc-stuff-ecdc45374aecdbcdb5c1d374742d9c528fb8298e.tar.gz
c-stuff-ecdc45374aecdbcdb5c1d374742d9c528fb8298e.tar.xz
c-stuff-ecdc45374aecdbcdb5c1d374742d9c528fb8298e.zip
More code.
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;
}