Even in a command-line terminal environment, we can code to accept real-time user (keyboard) input.  Accepting data from the user's typing is never straightforward.  The user can enter the wrong type of data, the wrong size of data, or even somehow enter unexpected keys.  We only casually view input function 'scanf()' here.


(right-click to download)

/* pgm11 source */

#include <stdio.h>
#include <string.h>
#include <ctype.h>    // for 'toupper()' - change character from whatever case to UPPER case

#define S_LEN 65
#define STRNULL '\0' // string terminator

void uppercase(char []);

int main(void) {
char strn[S_LEN];

printf("\nEnter a few-word string (then ENTER/RETURN): ");

// the INPUT format '%[^\n]' provides a way
// for scanf() to read input that has spaces

scanf("%[^\n]", strn);


printf("\nYour input string capitalized: %s\n\n", strn);

void uppercase(char *strn) {       // more details on this function in the article
     while (*strn != STRNULL) {
          *strn = toupper(*strn);