AllExperts > Experts 
Search      

C

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More C Answers
Question Library

Ask a question about C
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Prince M. Premnath
Expertise

I'm sure that I can solve any doubts in Turbo C ,Graphics Programing ,Mouse, Hardware Programming ,File System ,Interrupts, BIOS handling , TSR Programming , General Concepts in C Language, handling inline Assembly statements

Experience
  • Experience in this area :
  • Research over 4+ years.
  • Education/Credentials :
  • Masters in Computer Applications
  • Organization belongs to :
  • ST Joseph College (SFS) Trichy

 
   

You are here:  Experts > Computing/Technology > C/C++ > C > How to save asin Values in a file ?

Topic: C



Expert: Prince M. Premnath
Date: 3/24/2008
Subject: How to save asin Values in a file ?

Question
Hi,
I have one question related to filehandling in c.
Q:How i can store the different values of a sine wave equation
y=a sin(wt)in a file in the form of matrix.
i would be greatful if u could help me out for finding a solution.
Thanks and Regards,
Smita

Answer
Hai Dear Samita !

 Perhaps its simple to store the values of a sine wave equation, just follow the simple steps .

1. Create simple structure with two members say x , and asin of type double.
eg
  struct sinvals
  {
      double x;
      double val;
 }structvar;
2. Create a structure variable .
3. Read the value of x  , and calculate the corresponding asin value of x using the built in function and store the result in the member val.
4. Now write the contents of the structure variable onto the output file

Using this statement !

fwrite(&structvar , sizeof(structvar) , 1 , fileptr);

The code given above is self explanatory , say structvar is structure variable , fileptr refers the pointer to the output file ! the 3rd argument 1 refers number of records to be written on file !

For more queries and doubts feel to post a follow up !

Thanks and Regards !
Prince M. Premnath  

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.