By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,799 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

Output file prob

Savage
Expert 100+
P: 1,764
I'm making for fun a simple program which format a input file.Input file sustain of
person name,lastname and date of birth.Output file si supposed to be forammted as following:

NAME LASTNAME DATE OF BIRTH

And i finished it but there is little prob: it don't output date of birth!

I thinkt about the prob and can't figure out why is that happening.

To output data i used function: void output(void),i have also created a struct:
Expand|Select|Wrap|Line Numbers
  1. typedef struct person{
  2.                                            char lastname[20];
  3.                                            char firstname[20];
  4.                                            char dob[10];
  5.                                }Tperson;
And here is a problem:

Expand|Select|Wrap|Line Numbers
  1. Tperson person;
  2.  
  3. while((!feof(data))&&(fgets(string,80,data)!=NULL))
  4. {
  5.      i=0;
  6.      j=0;
  7.     /*part with NAME and LAST name is working just fine so I don't think that   
  8.       this part is necsasary.*/
  9.      while(string[i]!=' '&&string[i]!='\t'&&string[i]!='\n')
  10.      {
  11.            temporary[j]=string[i];
  12.            i++;
  13.            j++;
  14.       }
  15.       temporary[j]='\0';
  16.       strcpy(person.dob,temporary);
  17.       fprintf(out,"\n %10s  %10s  %
  18.       6s  ",person.firstname,person.lastname,person.dob);
  19.  
  20. }
Did anyone noticed where did I went wrong??

Savage
Mar 31 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.