Responder1
Aproximação muito curta:
\documentclass{article}
\usepackage{tikz}
\newcommand\xoutofeight[2][black]{%
\begin{tikzpicture}
\pgfmathsetlengthmacro\xstep{.6cm}
\pgfmathsetlengthmacro\ystep{\baselineskip}
\fill[#1!40] (0,0) rectangle ({#2*\xstep},\ystep);
\draw[#1,xstep=\xstep,ystep=\ystep] (0,0) grid ({8*\xstep},\ystep);
\end{tikzpicture}}
\begin{document}
short num: \xoutofeight{2}
char* str: \xoutofeight{8}
short num: \xoutofeight[green!80!black]{2}
\end{document}
Responder2
Tabulares simples com xcolor
e array
podem fazer isso:
\documentclass{article}
\usepackage{array}
\usepackage[table, svgnames]{xcolor}
\begin{document}
\begin{center}
\setlength{\arrayrulewidth}{1.5pt}
\begin{tabular}{|*{8}{p{0.5cm}|}}
\hline
\rowcolor{WhiteSmoke!60!Lavender}& & & & & & &\rule{0pt}{1.5cm} \\
\hline
\end{tabular}\vskip 1cm
\begin{tabular}{|*{2}{>{\columncolor{WhiteSmoke!60!Lavender}}p{0.5cm}|}*{6}{p{0.5cm}|}}
\hline
& & & & & & &\rule{0pt}{1.5cm} \\
\hline
\end{tabular} \end{center}
\end{document}