why do you need a function which detects a white space?
and which "display-function" you want to use?
please also note this:
Code
#include <stdio.h>
void main(void) {
char asdf1[3] = "Hi";
char asdf2[3] = {'H', 'i', 0};
char asdf3[5] = "Hooo";
char asdf4[5] = {'H', 'o', 'o', 'o'};
char asdf5[5] = "Hi";
char asdf6[5] = {'H', 'i', 0, 'x', 'w'};
printf("asdf1: %s\n",asdf1);
printf("asdf2: %s\n",asdf2);
printf("asdf3: %s\n",asdf3);
printf("asdf4: %s\n",asdf4);
printf("asdf5: %s\n",asdf5);
printf("asdf6: %s\n",asdf6);
}
minimum size for saving 2 chars as a string is 3 bytes, if you want to use printf to display the string. if you forget the terminating null byte, the behaviour may be unexpected.
minimum size for saving 4 chars as a string is 5 bytes. the last one should be zero. if you write the string with doubled quotes, the compiler automatically adds the zero.
if you have too many chars but you dont need them all, it doesn't matter what you have after the first zero.
also note, that the whitespace is not the zero (look at ascii). if you want to add a whitespace to the monstername, just replace the letter with ' ' (those single quotes are required, lol). you could also insert the value 32
This post was edited by Richter on Mar 26 2013 04:08pm