C++ :: File Input And Output Structure

Jul 17, 2013

How to structure the input of one .dat file and outputting into another one. I have to loop through a file structured "doe, john, 1500", check for errors and then increase the mp by 50. You also have to do this through using a person class too. I think I need to use a while loop to go to eof and use getline to input correctly, but im not sure how to structure it.

Data file:
Horowitz,Jake,1200.24
Flabitz,Bubba,1712.38
Blackwell,Sharon,1872.93
Molerat,Rufus,501.00
Goodall,Jane,1567.43
Sommerset,William,1359.57

[Code] ......

View 4 Replies


ADVERTISEMENT

C++ :: Multiple Of CSV File Used As Input / Extracting Data To A Output File - Getline Function

Jun 4, 2013

I have written a C++ program I have multiple of CSV file used as input, which I open one at a time and close it after extracting data to a output file which is the only file.

I run getline(inFile,line);
outFile << line << endl;

I run this code, and only part of it is goes to the output file I got, also have spacing randomly to specific file and inconsistent

But when I slower the code, like system("Pause") in the loop, I can get extract what I want perfectly....

Is my program running to fast, why getline would be skipping part of what things I want?

View 11 Replies View Related

C :: Program To Calculate Students Grades From Input File And Write To Output File

Aug 29, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:

John K. 99, 87, 57, 89, 90, 95
Amanda B. Jones 100, 88, 76, 99, 86, 92
etc..

The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.

Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

[Code]....

View 2 Replies View Related

C :: Computing Grades From Input File And Writing To Output File

Aug 31, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows: John K. 99, 87, 57, 89, 90, 95 Amanda B. Jones 100, 88, 76, 99, 86, 92 etc.. The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the next (2) at 15% each and the final at 30%. Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:
//
// main.c
// Final Exam
//

[Code].....

The problem I'm having now is how to go about passing the grades to the function computeGrade and then compute the average and return that to the function.

View 4 Replies View Related

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 :: Naming Output File Based On Input File Name

Sep 7, 2013

I have a program where I will read in a certain .txt file, such as "financial_data.txt" and I will be doing some sorting with this data.

I want my program to write out the sorted data to an output file and I want the name of the output file to be based off of the input name. For example, since my input file is "financial_data.txt", I want the output file name to be "financial_data_out.txt".

I am having a hard time finding examples online and in my reference manuals...

View 4 Replies View Related

C++ :: Remove Comments From Input File And Then Put It Into Output File

Mar 11, 2013

I have written this code to remove the comments from an input file and then put it into an output file. The program compiles and runs but it removes the whole line of code when it encounters a /* */ type comment. I believe the problem is in the while loop but I just don't know where.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(void) {
string infile, outfile;
ifstream source;
ofstream target;

[Code]...

View 3 Replies View Related

C++ :: Read Input File (XML) And Generate Output File

Mar 25, 2013

I have code that reads an input file and generates an output file .For reading the input file we have a xml file.If there is an error while reading or writing the output file the an errored file is generated. But in the errrored file the fields are not coming as in accordance with the reader xml . They are coming randomly . In the module for reading and writing the errored file list is being used . What should be done to write in the errored file as the reader xml fields.

View 1 Replies View Related

C++ :: Read Input File (XML) And Generate Output File

Mar 25, 2013

I have code that reads an input file and generates an output file .For reading the input file we have a xml file.If there is an error while reading or writing the output file the an errored file is generated. But in the errrored file the fields are not coming as in accordance with the reader xml .they are coming randomly . In the module for reading and writing the errored file list is being used . What should be done to write in the errored file as the reader xml fields.

View 1 Replies View Related

C++ :: String Input AND Output To File

Sep 15, 2013

I'm trying to write a simple program that will prompt for a string typed in by keyboard and save it to a file. I've tried lots of variations and this is just the latest version.

//Prompt for a string input by keyboard and save it to a file

#include<iostream>
#include<fstream>
#include <string
using namespace std;

[Code] .....

View 2 Replies View Related

C++ :: Input / Output Text File Manipulation Not Working

Mar 24, 2013

Why my output screen for this program does not want to stay open. It only opens for a split of a second and it's gone. The program is supposed to take numbers from a input file and display and save the manipulation in the output file. Here is the program.

Code:
#include<iostream>
#include<fstream>
#include<iomanip>
usingnamespace std;

[Code] ....

View 6 Replies View Related

C++ :: File Input And Output - Creating Graph Plotting Points

Feb 10, 2014

So I am trying to create a program that reads a series of files and creates a graph plotting points from the file. So far my code looks a little something like this -

include <iostream>
include "ccc_x11.h"
include "ccc_shap.h"
include "ccc_win.h"
include <fstream>
using namespace std ;
int ccc_win_main() {
cwin.coord(-10, -10, 10, 10);

[Code] ....

However when I run the program nothing happens. I think it has to do with the way I set up my files, which looks a little something like this-

-9 -9 -9 -9 -9 -9 -7 -7 -6 -6 -5 -5 -4 6 3 1 -1 -3 -6 5 -5 4 -4 2 -2 0

The first thirteen numbers are the x values of the points, and the last thirteen are the y values of the points. Is there any other way to have my program read the file and display the given points?? I would use getline() however that would make my point into a string, and I dont really know how to convert a string to a double before putting the variable into a point.

View 2 Replies View Related

C++ :: File Input / Output - Getting Highest And Lowest Number From A List Of 7 Numbers

Apr 16, 2013

I am currently confused on how to get the highest and lowest number from a list of 7 numbers for a File Output. Lets say i have 165 19 654 816 654 987 324. How would i get the 987 for the highest and the 19 as the lowest? Those numbers are not fixed numbers, i need to be able to input any combination of numbers and still be able to get the highest and lowest numbers from the list of 7 numbers.

View 1 Replies View Related

C++ :: Read Story From Input File / Separate Words And Output Lines On Which The Word Occurs

Feb 21, 2014

I have program that is supposed to read in a story from an input file and separate the words and output the lines on which the word occurs. It needs to read in another input file that has a list of words (1 per line) to ignore. i.e. skip them when running through the story. This is what I have so far, I've changed multiple things trying to get it running....

#include<iostream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<string>
#include"split.h"

[Code] .....

View 1 Replies View Related

C++ :: Read Input From User And Then Store In Structure Variable

Apr 6, 2014

My program is designed to read input from the user and then store that input in a structure variable. Whenever i use the cin.getline() function, it comes up with a semantic issue. Here is the code:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int DESCRIPTION_SIZE = 100, DATE_SIZE = 20;
struct inventory {
string description[DESCRIPTION_SIZE];

[Code] .....

I left out the other functions. The error reads "no matching member function for call to 'getline'.

View 6 Replies View Related

C++ :: Creating List Of Medical Resources And Their Attributes - Input To Structure Array Not Working?

Mar 23, 2014

I wrote this program to create a list of medical resources and their attributes, a task I have been performing repeatedly lately. I'm still fairly new to C++, so I thought to create a structure "Resource", and then an array of those structures "city[300]". My problem is that the input doesn't seem to be happening: the program runs, but when it prints to screen/writes to the file at the end, all the shows is:

Resource Type:
Name:
Address:
Phone:
Website:

for every resource that was input. All the fields are blank.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct Resource {
string typeID;
string name;

[Code] ....

View 1 Replies View Related

C :: Redirecting Input And Output

Sep 14, 2013

I have this code:

Code:

#include <stdio.h> //printf
#include <stdlib.h> //exit
#include <unistd.h> //fork
#include <sys/types.h> //pid_t
#include <sys/wait.h> //waitpid
}

[code]....

I would like to, when running cat, send in some data like "testing" to its stdin, and then catch the output of stdout, and put it into a character array variable.Currently the parent stalls till the child is done.I imagine the parent has to some how detect that the child executed 'cat', and then send in input to stdin?Then somehow detect that 'cat' is done executing, and read the output from stdout? I have looked around and found "dup2", but I don't understand how to send in and get data to the child from the parent, especially since the "file descriptors" is not pointing to any files in the first place..

View 4 Replies View Related

C++ :: Audio Input / Output?

Feb 5, 2015

So I have a project in which I am processing audio signals in real-time. I want to create a class to do this using the ASIO driver. I don't want to use a cross platform library nor do I want to use windows API as it is very slow.

View 2 Replies View Related

C/C++ :: Console Input / Output?

Sep 7, 2014

I'm trying to write something that when a user is at the command line, the user can type and it displays of list of commands the user can use to run the application.

View 14 Replies View Related

C++ :: Zero And Output The Input With A Setprecision Of 2

Mar 31, 2013

I have a program that needs to output the input with a setprecision of 2 but when it outputs 0, it has to be "0", not "0.00"

How will I go about that?

Here is my code:

void PrintAllSales(double sales[][SLSPRDT]) {
cout << fixed << showpoint << setprecision(2) << endl;
cout << "ALL SALES
";
WriteLine('=', 63);

[Code] .....

And here is how it comes out:

1234
ALL SALES
===============================================================
Product # | 1 | 2 | 3 |
Salesperson 1 | 2000.00 | 0.00 | 299.00 |
Salesperson 2 | 0.00 | 2543.98 | 95.99 |
Salesperson 3 | 0.00 | 0.00 | 19.99 |
Salesperson 4 | 0.00 | 3854.75 | 0.00 |

But it should be like this:

1234
ALL SALES
===============================================================
Product # | 1 | 2 | 3 |
Salesperson 1 | 2000.00 | 0 | 299.00 |
Salesperson 2 | 0 | 2543.98 | 95.99 |
Salesperson 3 | 0 | 0 | 19.99 |
Salesperson 4 | 0 | 3854.75 | 0 |

View 7 Replies View Related

C/C++ :: How To Save New Input Using Output

Sep 11, 2012

I have a project, a montly paycheck. So it checks the monthly paycheck of each employees. but my problem there is how to add a new employee when u are a user or in the output of program?

View 2 Replies View Related

C++ :: String Integer Value - Input / Output

Aug 14, 2013

Code:
Prompt the user to input a string,
and then output the sum of all the digits in the string.

Sample Run 1:
Input -> A111B222C
output -> 9

Sample Run 2:
Input -> ABC123XYZ32100000005555555555zzzzzz
output -> 62

View 1 Replies View Related

C :: How To Arrange Input / Output Order

Sep 22, 2014

for our school project, we have to make a program which involves three students and the prices each of them paid for the meals. The program has to calculate how much each of the students has to pay/receive to/from the others. Most of it, we got from our teacher. The error we are getting is that we have to 'take care of the input/output order'. So if you type in the names/numbers of the students in a different way, so for example if you type first number 1, then 0, then 2 and 0 and 1 have to pay money to number 2, number 0 has to be in front of 1. Our output is that number 1 is in front of number 0.

insert
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

[Code].....

View 1 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++ :: Assigning Input To Value - Random Output

Jul 24, 2014

I'm using getline, and stringstream to assign an input to a value. How to do something similar with a random output.

//Battle with Samer
#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
#include <cstdlib>
using namespace std;

const char* PokemonSamer[6] = {
"Charizard", "Umbreon", "Mew", "Arcanine", "Espurr", "Luxaray"

[Code] ....

When I run <PokemonSamer[rand() % 6]>, I want to be able to save whatever that output may be, and save it to <string Samer>. Is this possible?

View 6 Replies View Related

C++ :: Input And Output Array Using Function

Apr 25, 2013

I want to create a function that will accept input from the user and return the input, to be used for further calculation. I know how to accept and return with integers as parameters , but how do i do it with arrays?

Suppose there is an array of numbers arr[]. Now, i want a function that accepts the input from the user, and return the array for further manipulation.

For example, if the array is arr[5], then i should call a function and accept the values from the user. Then, i should return the imputed values and print the same. How can i do this.

View 3 Replies View Related







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