If You Want Something To Do, Try This Exercise...

Define a human struct that has 3 fields:

char name[50];
char gender[10];
int age;

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??!!

9 Years
Discussion Span
Last Post by Salem

>>If You Want Something To Do, Try This Exercise...
Ok, wrote, compiled and debugged in 22 minutes. Except I used a linked list instead of an array. (This is my day off from work so I have lots of time to spare :) )

Votes + Comments

The title should have been "if you want to do something in life then do my homework for free , god will bless you and you will go to heaven. "

Votes + Comments
Perfect 10/10 for quote !!! Ha ha ha ...

>If You Want Something To Do, Try This Exercise...

If you are free, try this exercise:
Repeat 10 times a day : " Hackers aren't stupid. Programmers are not stupid."
And you will magically get the answer.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.