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

>If You Want Something To Do
Yes, I want to give you some links you should consider looking at before you start posting on this forum:

Read this before posting
Forum announcement I
Forum announcement II

Come back when you've read them :)

(It will take you a couple of minutes to read them, but it will save us lots of time we can use to help other people)

>>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 :) )

commented: LOL :D +7

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. "

commented: haha +10
commented: Perfect 10/10 for quote !!! Ha ha ha ... +1

>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.

<yoda>Do or do not, there is no try</yoda>
Only then, Jedi master of the source will you be, mmmmmm.

commented: Great master of Boolean logic Master Yoda is. +17
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.