Do my homework
If You Want Something To Do, Try This Exercise...
Define a human struct that has 3 fields:
Try and use typedef in your program for your struct.
Write a program that reads in a text file containing names, ages and gender of cartoon characters, which are separated using tabs and each character separated using a new line. For example:
Homer J Simpson 39 Male
Marge Simpson 38 Female
Bart Simpson 10 Male
Lisa Simpson 8 Female
Maggie Simpson 1 Female
You can probably tell, but tab characters separate each field above!
Read the file a line at a time. Store each person in an array of human structs (you'll need to allocate memory for the array dynamically since you don't know how many characters are defined in the text file).
Then print out all the original data, stating their name, age and gender.
Then do the same again but state their ages in 3 years time.
I know the Simpsons is a bad example as they've been on our screens for over 10 years and don't seemed to have aged at all! By the way, does anyone know how old is Marge??!!
Laughs! That's the funniest post I've ever read. Don't wanna be insulting, but the topic is clearly _against_ our policy.
Anyway, I have already done it. And you?
PS: Tab characters are not displayed correctly except when you use [CODE] tags.
Show some progress and people in this forum will definitely help you.
Originally Posted by heiroglikano
Well, even I feel this is giving the answer away...
Read the following man pages,
* man 3 fgets
* man 3 malloc / man 3 free
* man 3 sscanf
And that's about all you'll need, should take about 10 minutes.