Pangram checker: Difference between revisions

Content added Content deleted
(→‎{{header|TXR}}: Stray text removed.)
(→‎{{header|C}}: drop unneeded headers; slight cleanup)
Line 232: Line 232:
=={{header|C}}==
=={{header|C}}==
<lang C>#include <stdio.h>
<lang C>#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int isPangram(const char *string)
int isPangram(const char *string)
{
{
char ch, wasused[26];
char ch, wasused[26] = {0};
int total = 0;
int total = 0;


while ((ch = *string++)) {
memset(wasused, 0, sizeof(wasused));
while (ch = *string++) {
int index;
int index;


Line 250: Line 247:
else
else
continue;
continue;

if(!wasused[index]) {
wasused[index] = 1;
total += !wasused[index];
wasused[index] = 1;
total++;
}
}
}
return (total==26);
return (total==26);
Line 260: Line 256:
int main()
int main()
{
{
int i;
const char *pangram = "The quick brown fox jumps over the lazy dog.";
const char *not_a_pangram = "The qu1ck brown fox jumps over the lazy d0g.";
const char *tests[] = {
"The quick brown fox jumps over the lazy dog.",
printf("\"%s\" is %sa pangram\n", pangram, isPangram(pangram)?"":"not ");
"The qu1ck brown fox jumps over the lazy d0g."
printf("\"%s\" is %sa pangram\n", not_a_pangram, isPangram(not_a_pangram)?"":"not ");
};

for (i = 0; i < 2; i++)
printf("\"%s\" is %sa pangram\n",
tests[i], isPangram(tests[i])?"":"not ");
return 0;
return 0;
}</lang>
}</lang>