Thread: how do i send the results of a code to an output file and then view it?

  1. #1
    Registered User
    Join Date
    Jan 2015
    Posts
    1

    how do i send the results of a code to an output file and then view it?

    Hey, i'm sort of new to coding and have been reading through lots of different types of physics related programs that solve certain problems.

    In this one program (3 body problem), there are 6 inputs that are scanned (mass, velocity and position of the 2 bodies) and these inputs are computed to arrive at values for x, y and time for the third body. There is a working code that for of extremely small time steps, i.e over 5000 iterations, it produces values for x and y positions of the third body.

    I believe this info is sent to an output file since there is a:

    FILE* output=fopen("results.out", "w");

    I want to play around with the code, insert different values for mass and velocity of the two bodies, but I don't know how to view the results? Im guessing I need to create a results.out file somewhere, but how do I go about doing this?

    Do I need to assign memory to the results and then forward that to the output file somehow? Here is the code here if you need to look at it for more guidance:

    3body.c

    I have a compiler and what not, I'm just unsure how i can get these results out is all. Quick bit of help would be great thanks.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    The program seems to be getting the input data from the command line and writing the results to results.out. Did this program come with any documentation?

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to Send programme output to a printer ??
    By Chandan2 in forum C Programming
    Replies: 6
    Last Post: 08-13-2013, 10:37 AM
  2. Open file for output fails - really trivial code
    By robertwinz in forum C++ Programming
    Replies: 8
    Last Post: 08-04-2011, 04:48 AM
  3. What results in this output
    By Varuna in forum C Programming
    Replies: 1
    Last Post: 01-15-2010, 09:53 AM
  4. Send output to keyboard buffer
    By DReynolds in forum C Programming
    Replies: 2
    Last Post: 06-06-2007, 03:44 PM