C scrabble counter with piping input I want to start making some command line programs in C, this is a fork of something else I made but is more suitable to this site. My big question is there a better way to pipe commands? I think the way I did it feels improper. I especially feel the string method is a bit hacky.
#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;ctype.h&gt;
#include &lt;string.h&gt;
int main(int argc, char *argv[])
{
    char t[32767];
    unsigned int val = 0;
    if (argc == 2)
    {
        memset(t, '\0', sizeof(t));
        strcpy(t, argv[1]);
    }
    else
    {
        read(STDIN_FILENO, t, 32767);
    }
    for (int i = 0; t[i]; i++)
    {
        t[i] = tolower(t[i]);
    }
    int i;
    for (i = 0; t[i] != '\0'; i++)
    {
        switch (t[i])
        {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
        case 'l':
        case 'n':
        case 's':
        case 't':
        case 'r':
            val += 1;
            break;
        case 'd':
        case 'g':
            val += 2;
            break;
        case 'b':
        case 'c':
        case 'm':
        case 'p':
            val += 3;
            break;
        case 'f':
        case 'h':
        case 'v':
        case 'w':
        case 'y':
            val += 4;
            break;
        case 'k':
            val += 5;
            break;
        case 'j':
        case 'x':
            val += 8;
            break;
        case 'q':
        case 'z':
            val += 10;
        }
    }
    printf(&quot;%i\n&quot;, val);
    return 0;
}


I know this is similar to Scrabble word scoring, but I am less interested in the switch but the stdin and the piping.
General Observations
This code should work just fine, but performance can be enhanced.
Initialize Arrays to Zero at Compile Time
Currently there is a performance hit in the code when initializing the array t to zero. The function memset() is a runtime function, by initializing the array t to zero there is no run time cost:
    char t[32767] = {0};

The previous line of code initializes the entire array to zero (equivalent to the call to memset()) and should not affect run time.
Use Table Lookup Over Long Switch Statements
The Scrabble word scoring question linked to in this question uses a table look up instead of a long switch statement. Table lookup is better for 2 reasons, the first is that it will only be one line of code rather than at least 26 lines of code, the second reason is that table lookup should be much faster than the logic that implements the switch/case statement.
Magic Numbers
The code includes unistd.h for the definition of the symbolic constant STDIN_FILENO but the numeric constant 32767 is used multiple times rather than defining a symbolic constant for it. It would be better to define a symbolic constant for 32767 using either a const declaration or a #define preproccessor statement.
    const size_t INPUT_BUFFER_SIZE = 32767;

or
#define INPUT_BUFFER_SIZE 32767

This makes the code more readable and much easier to maintain, since an edit to change the value would only need to be performed on one line rather than having to search through the code to replace every instance of the numeric constant.
    char t[INPUT_BUFFER_SIZE];
    unsigned int val = 0;
    if (argc == 2)
    {
        memset(t, '\0', sizeof(t));
        strcpy(t, argv[1]);
    }
    else
    {
        read(STDIN_FILENO, t, INPUT_BUFFER_SIZE);
    }

Portability
The include file unistd.h does not port to Windows or some other non POSIX systems, which means this code won't even compile on some systems. While it is less readable, using zero is more portable, or have an ifdef in the code to define STDIN_FILENO on all systems.
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif

The Code Doesn't Allow for Switches on the Commandline
The code makes an assumption that there is no commandline switch that precedes the input to be processed if argc is greater than 1. This could result in bugs in the future. It might be best to have some kind of check for switches in the command line processing.
Complexity
If the code continues to use the switch/case statement then it would be better to move that statement into it's own function that returns an integer value.