Listing 2 The file setw.c

// setw -- setw(int)
#include <iomanip>

static ios& swfun(ios& iostr, int n)
       {       // set width field
       iostr.width(n);
       return (iostr);
       }

smanip<int> setw(int n)
       {       // extractor/inserter to set width field
       return (smanip<int>(&swfun, n));
       }