C :: How To Send Results Of Code To Output File And Then View It

Jan 18, 2015

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 : 3body.c

I have a compiler and what not, I'm just unsure how i can get these results out is all.

View 1 Replies


ADVERTISEMENT

C++ :: Decompress Input File And Write Results Into Output File?

Jul 8, 2013

how do i decompress an input file and write the results into an output file?

also my do while loop is supposed to keep going unless the user selects the option to exit the program, instead it exits after finishing ay of the options.

here's my code so far...

#include <iostream>
#include <iomanip>
#include <fstream>

[Code]....

View 1 Replies View Related

C/C++ :: Output To File Is In Hex Code

Apr 2, 2014

Here is program I have written which reads the destination, then finds it from a separate file, and reserves the information on a different file. But the reserved file has hex code information, how can I output my result to the file in normal alphabet/number/symbol characters? I've tried fputs,fprintf, and fwrite , and all give me the same result. The array c, is the one to be written to file.

void main {
FILE *afile = fopen("flightrecord.txt","r");
int i=0,j=0,k=0,z=0,y=0,sum=0,seat=0,g=0;
char destination[10],a[1000],c[1000],b[1000],name[100],last_name[100],c_number[15],plane[]={'P','6','2'};
printf("What is your destination?");
scanf("%s",&destination);

[Code] ....

View 14 Replies View Related

C++ :: How To Output File Into New Program Or Code

Apr 24, 2013

//code
ofstream outFile;
outFile.open("p4a.dat");
outFile << setw(8) << "90.0";
outFile << setw(8) << "75.0";
outFile << setw(8) << "36" << endl;

[Code] .....

View 1 Replies View Related

C/C++ :: Irrational Results In Bounded Pareto Distribution Code

Jan 24, 2015

I wrote the bounded pareto distribution and I add it to simulator but I have irrational results (job sizes between 0.00000-1.1111)

double b_pareto(k,q)
double k; // the K vaue represents a lower limit of job size
double q; // the q vaue represents an upper limit of job size {
double a = 1.5; // alpha value
double rv; // the Returened Value

[Code] ....

View 4 Replies View Related

C++ :: Merge Sort Algorithm - Output Random Results

Sep 16, 2012

I am trying to code a merge sort algoritm, using my knowledge of C++. I have made some code but it is not working. It is giving some random results.

Code:

#include <cstdlib>
#include <iostream>
using namespace std;
void print(int *niz) {

[Code] ....

View 1 Replies View Related

C :: How To Send Programme Output To A Printer

Aug 10, 2013

I want to print the output of a c programme to a printer. Operating system is MS Windows xp sp2. This is the programme:

Code:
#include<stdio.h>
#include<conio.h>
void main()
{
printf("
Hello Chandan2... ");
getch();
}

The output "Hello Chandan2..." is to be printed in printer, when i run the programme , but how to do it?

View 6 Replies View Related

C++ :: Get Input From Ports And Send Output

Jul 30, 2014

I'm learning C++. Is there some way to make program function on input from a port like usb port and can I send bits through the port? For example A usb cable connected to a circuit. I press a button and an AND gate on the circuit gets activated by a bit from the usb port and a fan in the room turns on.

View 1 Replies View Related

C# :: Populating Second View From Info In First View

Jul 22, 2014

I have a program I have been working on where the user selects a date and enters the number of days to be viewed in the Calendar.cshtml view. This input renders another view (Update.cshtml) that contains two date picker boxes, one that should contain the selected date and the second one that should contain the calculated date. I am having an issue getting the date selected in the first view to populate to the first date block on the second view as the default and getting the calculated date to populate the second date block in the Update.cshtml view. In addition given the two dates, I would like to generate a calendar, which is why I chose the date picker approach and setting static dates.

Here is my code:

**CalendarController:**

using System.Web.Mvc;
using VanickCalendarApp.Models;
using System;
namespace VanickCalendarApp.Controllers {
public class CalendarController : Controller {

[Code] .....

View 5 Replies View Related

Visual C++ :: Display Data Of Text File In List View

Sep 24, 2012

I want to display data from text file in list view and in tree view root will be file name, but i dont know how to do it, the problem is with displaying text file data in list view, i don't know anything about that. text file data is very simple. It is just a square matrix of double values like:

21.06 34.06 5.0
12.78 45.25 6.9
12.89 45.98 5.5

in list view i want to display it.

View 14 Replies View Related

Visual C++ :: Resource View Takes Hangs When Trying To Edit Rc File

Mar 15, 2013

Found an online suggestion of using an rc2 file and cut and paste stuff from .rc file to .rc2 file to see which line causes the problem but don't know how to create a blank .rc2 file. Problem started after I ported from VC++ 6 to VS2010.

View 5 Replies View Related

Visual C++ :: Launching Current Version Of IE To View HTML File From Program

Nov 29, 2012

I tried to do this with _spawnl(), but first of all I'm not sure how to properly ask for the path to iexplore.exe, as I'm sure it will change every time MS gets a whim to move it. I know there's a GetWindowsDirectory() call, but that's not where IE resides (its in "C:Program FilesInternet Exploreriexplore.exe" in XP, Lord know where on win 7 or 8).

Also, even temporarily hard coding the path to make it launch with spawnl(), I can't seem to get my html document to display. I know the path to that is right (since I put it there ).

char * pFile = "someFile.htm";
char * pCmd = "C:Program FilesInternet Exploreriexplore.exe";

int res = _spawnl(_P_NOWAIT, pCmd,pCmd, pFile, NULL); // also tried without specifying pCmd 2x
if (res == -1) MessageBox("Can't Open File.");

So my second question would be, how to you PROPERLY pass the file to view as an argument.

View 7 Replies View Related

C/C++ :: How To Find Output From A Block Of Code

Feb 2, 2015

int a = 9, b = 4, c = -1;
c *= --b * a;

View 1 Replies View Related

C/C++ :: Drivers License Exam (Read Results From File)

Apr 14, 2015

How to get this code to compile and build. It gives me a really strange error saying:

"1>Project 7 Code.obj : error LNK2019: unresolved external symbol "void __cdecl checkAnswers(char * const,char * const,int,int)" (?checkAnswers@@YAXQAD0HH@Z) referenced in function _main
1>C:UsersHaruha Raharu HarukoDesktopSpring 2015 Class WorkIntro to ProgrammingProject 7Project 7DebugProject 7.exe : fatal error LNK1120: 1 unresolved externals"

Here is the specifics on the assignment:

"Complete Programming Challenge #12 (Driver's License Exam) with file modification

The State Department of Motor Vehicles (DMV) has asked you to write a program that grades the written portion of the driver's license exam, which has 20 multiple choice questions.

Here are the correct answers:

1. B 5. C 9. C 13. D 17. C
2. D 6. A 10. D 14. A 18. B
3. A 7. B 11. B 15. D 19. D
4. A 8. A 12. C 16. C 20. A

Create a TestGrader class. The class will have an answers array of 20 characters, which holds the correct test answers. It will also have a student array of 20 characters to hold the student's answers. It will have three public member functions that enable user programs to interact with the class: setKey, setStudent, and grade. The setkey function receives a 20-character string holding the correct answers and copies this information into the answers array. The setStudent function will read in the student's answers from the file student.txt and will store the answers in a 20-character array named student. The grade method will compare each student answer to the correct answer in the key.

An applicant must correctly answer 15 or more of the 20 questions to pass the exam. After grading the exam, the program should display the following items:

-the number of right answers and the number of wrong answers
-a list of the question numbers for all incorrectly answered questions
-a message indicating whether the applicant passed or failed the exam"

View 5 Replies View Related

C++ :: Output Sections Of Txt Code In Random Order

Mar 27, 2014

I will keep this simple as I have the code written for my testing software program, I just want to add a feature of randomly generating the answer choice output order, I do not want to randomly output the full questions, but instead the choices (answers to the question), for example =

#include <string>
#include <iostream>
#include <limits>
cout <<" " << endl ; \ space

[Code] ....

As you can see I would like to output the answers, choices randomly as in answer choice 3 will appear at the top instead of 1. and so on, it doesn't matter if the numbers move with the txt as the numbers beside the
questions are txt.

It's a 32bit console application.

View 4 Replies View Related

C++ :: Program To Merge Numbers In Two Files And Write Results To Third File

Apr 9, 2013

I need to write a program that merges the numbers in two files and writes the results to a third file. The program reads input from two different files and writes the output to a third file. Each input file contains a list of integers in ascending order. After the program is executed, the output file contains the numbers from the two input files in one longer list, also in ascending order. Your program should define a function with three arguments: one for each of the two input file streams and one for the output file stream. The input files should be named numbers1.txt and numbers2.txt, and the output file should be named output.txt.

View 1 Replies View Related

Visual C++ :: Throttle Binary File Download Via WinHTTP Gives Unexpected Results

Nov 11, 2014

My Windows service may download a binary update in the background using WinHTTP APIs. I'm using code similar to the one from the bottom of this MSDN page. For ease of access I'll copy if below:

Code:
DWORD dwSize = 0;
DWORD dwDownloaded = 0;
LPSTR pszOutBuffer;
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;

[Code] ....

The issue I'm experiencing is that while downloading, the code above "hogs" most of the bandwidth available on the client computer. My goal is to make it "throttle" itself on a configurable "bps" level, say at 50 kbps and not use any more bandwidth.

Someone suggested measuring my current download speed (in bps) and depending on the value make the thread "sleep" before calling WinHttpReadData again.

So the formula I'd use to calculate BPS is this:

BPS = (BytesDownloaded * 1000 * 8) / TimePassedInMilliseconds;

Then to convert to Mbps:

Mbps = BPS / (1024 * 1024);

And the waiting/sleep would be done as such:

Code:
DWORD DesiredBitsPerSec = 50 * 1000;//for 50 kbps
if(fBps > DesiredBitsPerSec) {
DWORD dwW = (DWORD)((fBps - DesiredBitsPerSec) * 1000) / DesiredBitsPerSec;
if(dwW > 0)
::Sleep(dwW);//Sleep to throttle the download speed to the one we need
}

So I implemented it into the code above but it didn't work -- the Sleep API would produce very strange delays. So I decided to add a little bit more tracking code to actually be able to see what BPS values I'm getting.

I created a small test project that is attached to this post to illustrate the issue. (It's hard to explain without running an example.)

For a test I began downloading a large binary file (Windows 10 MSI, off Microsoft's server) and at the same time had the Task Manager open on a Performance tab that was showing me the current network throughput. I made a screenshot:

But as you can see, the reading on the test program and the actual network BPS values differ greatly.

View 1 Replies View Related

C/C++ :: How To Send PPM To A Function In Another File

Apr 7, 2015

I have an assignment where I have to alter a ppm image and send it to a function in another file to print the new altered version.

#include "transform.h"    
int main (int argc, char *argv[])  {  
    // declarations here
    FILE *inFile;      
    // open input file 
    inFile = fopen("tiger.ppm", "r")

[Code] ....

View 1 Replies View Related

C++ :: Send String As Argument To TXT File

Apr 8, 2014

I have a function which send a string as argument to a txt file, like the following:

void Fprint(... ofstream& myfile, const string a, const int b)
......
myfile << "name: " << a << " age:" << b << "" << endl;
......
}

However, my IDE (msvc12.0) popup an error about the << before a, by citing "No operator matches these operands.

View 2 Replies View Related

C/C++ :: Send JPG File From Client To Server?

Feb 27, 2013

Share ur code wit my. m working on windows n using visual studio 2008..

View 1 Replies View Related

C :: Correct Way To Send A File As A DIME Attachment

Apr 9, 2013

I am trying to send a DIME Attachment as a HTTP POST using the libcurl. I using this to communicate with a SOAP API. All my other function work properly but I find the correct way to send a file as a DIME attachment.

View 4 Replies View Related

C/C++ :: Trying To Get Server To Send Contents Of Txt File To A Client

Mar 2, 2015

Here is what I got so far, I am not able to send whats in the txt file to the server. Its pretty much a txt file with movie names and when the client types the name, it brings up the movie and its ranking (all from the txt file)

Server Code::

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <string.h>
#include <fcntl.h> //file control

[Code] .....

I attached the images of the client and server when I run this, along with the movie.txt file. I cannot seem to get the file to send to the client?

Attached image(s)

View 9 Replies View Related

C/C++ :: Send Contents Of TXT File From Server To Client

Mar 2, 2015

I am not able to send whats in the txt file to the server. Its pretty much a txt file with movie names and when the client types the name, it brings up the movie and its ranking (all from the txt file) .....

Server Code::

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

[code]....

I attached the images of the client and server when I run this, alongside the movie.txt file. I cannot seem to get the file to send to the client

View 1 Replies View Related

Visual C++ :: Wininet Application Does Not Send To PHP File

Jan 23, 2015

This code doesn't send parameters to mysql database vis WININET post, i see it send empty fields, what exactly could be the problem:

Code:
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include <Wininet.h>
#define PAGE_NAME "gate.php"

[Code] ....

View 13 Replies View Related

C++ :: Send Binary Data (BMP File) To PHP Script

Oct 5, 2014

I found the following code in [URL] ....., that send .TXT files perfectly to php script in my server using Wininet, but when I insert a .BMP file, this file (.BMP) is correctly created and named in server side, but it is empty! I read that is necessary implement base64 encode for work properly, so how would?

PHP Code:

  #include <windows.h>
  #include <wininet.h>
  #include <iostream>
  #define ERROR_OPEN_FILE       10
  #define ERROR_MEMORY          11
  #define ERROR_SIZE            12

[Code] ....

View 12 Replies View Related

C :: Send To Another Host Via HTTP Post And Existing XML File

Oct 6, 2014

My user requires that I add function to an already working C server that will send to another host via http post and existing xml file. I have googled and found C# and C++ on how to do this but nothing using C. Where do I start?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved