#include <stdio.h>
#include <conio.h>
main()
{
int i;
char string[500];
char ch;
printf("Enter data. Press Esc when you complete typing.\n");
ch=getche();
i=1;
while(ch!=27)
{
ch=getche();
string[i]=ch;
if(ch==13)
{
printf("\n");
i++;
}
if(ch==32 || ch==9)
{
i++;
}
}
printf("\nYou have enter %d word(s).", i);
getch();
}
Q:. what kind of inputs are most likely to uncover bugs if there are any?
Ans:. Semantic definition of word, some special cases:
- link word: "cat-walk"
- small word: a, b,c
- biiiiiig words: "a fooooooooo<40MILLIONLETTERS>ooooooo a" has 3 words
boundary conditions:
- Texts with multiple spaces between words.
- Texts bigger than 2GB
- Words which contain a dash but no whitespace.
- Non-ascii words. (e, g: Ellipsis, registerd sign, gegrees)
- Files in some different encoding (if your program supports that)
- Characters which are surrounded by whitespace but do not contain any word characters (e.g. "hello - world")
- Texts without any words
- Texts with all words on a single line