Miscellaneous > Programming & Networking

C++ Read File

(1/1)

yourlife:
Hiya.
I want C++ to output the contents of a text file.
The text file is like this:

--- Quote ---Bugs Bunny, Daffy Duck, Tree House
Steve Jobs, Bill Gates, Bedroom
--- End quote ---
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.

Refalm:
I don't know anything about C++. So I made an AWK script instead.

--- Code: ---#!/bin/sh
gawk '
BEGIN { FS = ","; print " Name        | Friend      | Place\n ------------|-------------|------------" }
{ printf "%12s |%12s |%12s\n", $1, $2, $3 }
' looney.txt
--- End code ---

Navigation

[0] Message Index

Go to full version