Stop Microsoft
Miscellaneous => Programming & Networking => Topic started by: yourlife on 22 August 2010, 21:09
-
Hiya.
I want C++ to output the contents of a text file.
The text file is like this:
Bugs Bunny, Daffy Duck, Tree House
Steve Jobs, Bill Gates, Bedroom
And I want my C++ (CUI app) to display it like this:
Name | Friend | Place
-----------|------------|------------
Bugs Bunny | Daffy Duck | Tree House
Steve Jobs | Bill Gates | Bedroom
Obviously the two top lines can be done with C Out, but its the actual file that I can't do.
P.s. I'm new to C++!
P.s.s. I'm using Windows, Visual C++ 2010.
-
I don't know anything about C++. So I made an AWK script instead.
#!/bin/sh
gawk '
BEGIN { FS = ","; print " Name | Friend | Place\n ------------|-------------|------------" }
{ printf "%12s |%12s |%12s\n", $1, $2, $3 }
' looney.txt