You are here:

C/How to save asin Values in a file ?

Advertisement


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  

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


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

Research over 6+ Years

Organizations
CG-VAK Softwares and Exports Limited

Education/Credentials
Masters in Computer Applications

©2012 About.com, a part of The New York Times Company. All rights reserved.