ECE 2524 - Write a simple `tolower` program

ECE 2524

Introduction to Unix for Engineers

Write a simple `tolower` program

Last modified

Background

Compile and Understand tolower.c

Starting with a file named tolower.c that we wrote in class:

#include <ctype.h>
#include <stdio.h>

int main() {
    int c;

    while((c = getchar()) != EOF) {
        putchar( tolower(c) );
    }
}

compile it

$ clang tolower.c

and run it with your own input from the keyboard

$ ./a.out
:Hello World
hello world
:^d

Name your output program

We ma find it useful to compile multiple, separate programs in the same directory, and it would be quite confusing if they were all named a.out. We can use the -o option with clang to supply an output name:

$ clang -o tolower tolower.c# explain
$ ./tolower
:Hello World
hello world
:^d