Visual C++ :: Reading Records From Input File And Do Some Statistics

Oct 1, 2014

The program will prompt the user to enter a every student's first and last name, major ( of 4 choices CMPS MATH PHYSICS or EECE ), and grade. it's agreed that the professor will enter the name NoMore to stop the entry.

the program willl then store the info in a txt file. after closing the input file, the program will open it again read the records one at a time until end of file, and do some statistics including: highest grade, average grade, and highest average by major.

Finally the program will print the results....

View 6 Replies


ADVERTISEMENT

C++ :: Read List Of Random Numbers From Input File And Calculate Statistics?

Nov 11, 2013

I need my program to read a list of numbers from and input file, random.txt, and calculate the following statistics on those numbers:

A. The number of numbers in the file.
B. The sum of all the numbers in the file.
C. The average of all the numbers in the file.
D. The largest number in the file.
E. The smallest number in the file.

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

[Code]......

This is what I have so far but I'm not sure if it is right. I can't get the input file to open.

View 3 Replies View Related

C++ :: Input File Not Being Read As Records

Aug 6, 2014

I've got a program to read the input file as records. The problem is all it does is cout Record Number etc but it doesn't grab the data.

#include <fstream>
#include <string>
#include <iostream>
using namespace std;
int main() {
const int RANGE = 12;
string tab[RANGE];

[Code] .....

View 5 Replies View Related

Visual C++ :: How To Delete Records In TXT File

Nov 19, 2014

I have to ask the user if they want to delete any records. The user can enter -1 to finish deleting records. I have to write the remaining records in an output file. I have this, but 1) it doesn't let me enter more than 1 id, and 2 it doesnt output anything to my output.txt.

records.txt
6
123 Jose Garcia 99
345 Luis Garcia 87
234 Jazlyn Soriano 79
456 Carter Sander 95
567 Natalia Soto 67
789 Isabel Santana 80

Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
class Student {
private:
int id;
string firstName;

[Code] .....

View 9 Replies View Related

C++ :: Reading Records From Files

Jan 28, 2014

Is there a way to indicate how many records exist in a given file? For example, vectors have the vector.size() command to show the number of given elements. Is there a such command for files and records?

View 6 Replies View Related

C++ :: Reading Input File Into Value

Feb 16, 2014

I am trying to read from my input file Transactions.data which is set up as follows

V 250190
A 250190 2008 4 8788.00 0.00 000
and so on and so forth.

I am trying to read my V then go to switch (decision) to choose my case and preform further functions. My problem is that i cannot get past the first line so if it was

V 213400
V 123456

My code is supposed to check that the ID (213400) is valid then go on to the next line but it wont do that and prints out the first ID 6 times. My code is as follows:

char descision;
ifstream input;
input.open("Transaction.data");
if (input.fail()) {cout << "File could not be opened." << endl;}
input >> decision;

[Code] ....

View 1 Replies View Related

C :: Reading Input Without Using Arrays - File I/O

Sep 23, 2013

I am having trouble with file I/O.

Let say I have an input file like this

x1 y2 b4
85 z4 x2

I'm trying to read the input without using arrays. I would use fscanf(*arguments*) to get the first char, which is x. Then I call it again to get the second one, which is 1. Now I would need to get the second input, y2. How do I skip the white space character to get to char y ? And is it an effective way to get all inputs though ? (each input, example x1, is read into a function).

View 3 Replies View Related

C++ :: Reading Input - Reaching End Of File Too Early

Apr 24, 2014

I'm reading input from a file using an ifstream. The program doesn't seem to read any characters but continually returns eof no matter what file I use. Even when I do ifstream.open(filename) nothing changes. This program is intended to be the lexical analyzer of a compiler, so symbols are returned to indicate what kind of input is in the file.

Here's the code:

#include "lex.h"
#include <cstlib>
#include <iostream>
#include <fstream>
//other functions
char Lex::getChar(){
ifstream input;

[Code] ....

I'm sure I messed up the initialization of the ifstream somehow.

View 1 Replies View Related

C/C++ :: Reading Input From A File And Then Storing It Into Array?

Feb 16, 2015

I need to read input from a file , which contains multiple sentences of varying lengths. After each new line char, i need to store that sentence into an array.

#include <iostream>
#include <cstring>
#include <fstream>
#include <cstdlib>

[Code].....

View 2 Replies View Related

Visual C++ :: How To Order Records In ACCESS By MFC Objects Like CDaodatabase Or CDaoRecordset

Dec 13, 2012

Table with primary key already set-down in ACCESS. when insert records into the table by Execute() function of cdaodatabase, to some extense, the records are not put behind the last record as wished, otherwise randomly into other places!

now i want to do some kind of operation to order the table after insertion by cdaodatabase or some others. how to?

View 4 Replies View Related

C++ :: Deleting Records From TXT File

May 8, 2014

Is this the right codes for deleting a recoed on the text file.

void dlte(){
string line, recorddate;
cout << "Please Enter the date of record you want to delete: ";
cin >> recorddate;
ifstream myfile;
ofstream temp;
myfile.open("herald.txt");

[Code] .....

View 1 Replies View Related

C/C++ :: How To Delete Records In TXT File

Nov 19, 2014

I have to ask the user if they want to delete any records. The user can enter -1 to finish deleting records. I have to write the remaining records in an output file. So, i have this, but

1) it doesn't let me enter more than 1 id, and
2) it doesn't output anything to my output.txt.

records.txt
6
123 Jose Garcia 99
345 Luis Garcia 87
234 Jazlyn Soriano 79
456 Carter Sander 95
567 Natalia Soto 67
789 Isabel Santana 80

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
class Student {
private:
int id;

[Code] ....

View 4 Replies View Related

Visual C++ :: Reading Image File?

Apr 26, 2013

I have a jpg file. I have extracted the width and the length of the image. I have done that with some codes and markers. Now I need the image data starts as from that place i would like read the data and print the pixel value. I would like to display the pixels later.

View 2 Replies View Related

Visual C++ :: Reading And Storing TXT File

Feb 12, 2014

I am trying to read and store a txt file with format below:

2.5;abc;2,4000
2.5;bef;3,2000
2.5;ref;3,1000

I try the fscanf( pFile, "%d;%s;%d,%d", buffer,buffer2,buffer3,buffer4 ); to store 2.5 to buffer, abc to buffer2, 2 to buffer 3 and 4000 to buffer 4 on first line.

However, it doesn't work. How can I achieve this? I want to read the 2nd line and so on.

Code:
char buffer[100]="";
char buffer2[100]="";
char buffer3[100]="";
char buffer4[100]="";
FILE * pFile=NULL;
pFile = fopen("C: est est.txt", "r");

[Code] ....

View 11 Replies View Related

C++ :: Number Of Records In Binary File Is In Decimal?

Oct 9, 2014

My size of binary file is 1920 KB and my struct size is 124 kb. now to find number of records in file I divided 1920/124 and it gives me 15.4.... do I add 1 to 15.4 and make it 16 or do i take it as 15?

View 9 Replies View Related

C++ :: Read Uneven Records From File Into Class

Oct 20, 2014

The following shows a sample input file for class called Training. How can I read these uneven records in to class?

1/12/2013
8:00 – 17:00
250.00
2
871012-10-5543 //---->>Participant ID and namess in training T2100
Tony
Stark
700607-10-6231

[Code] ....

An array of Training (based on the number read from the file) should be created dynamically then load all the details into each Training object.

View 7 Replies View Related

C/C++ :: Program To Print Alternate Records From A File

Aug 23, 2013

Code for the following.

How to print alternate records from a file using fseek?

View 5 Replies View Related

C++ :: Editing Saved Records In A Text File?

May 19, 2012

i have this program that i am undertaking.....this project needs to store customer details, edit them and delete them...now i am facing the problem of deriving a code to edit those details...

MY CODE

HTML Code:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main () {
int choice [1];
string name;

[code].....

View 4 Replies View Related

C :: Using Struct To Pull Records From A Colon Delimited File

Dec 15, 2014

I'm trying to write a C program that will take a file that is delimited by colons and separate it out in to 5 sections:

0002:0003:0002:0080:<HTML>
0002:0004:0002:0080:<BODY>

I have the struct code in place but not sure how to actually store each of the 5 parts in memory. Here is the code below:

Code:

#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
struct contents
{
int source,destination,type,port;
char data[50];
};

[Code]....

View 3 Replies View Related

C++ :: File Save Routine - Blank Records In Module

Jul 10, 2013

I have faced a strange problem in File Save Routine. I have written a module to save data to binary file . I have designed a structure and put information in that and save it to file . I save multiple such records one after other. I use fwrite , fflush instructions.

The module is working fine. I have saved near about 35 such files. But in one file , the module has saved Blank Records. The file size if perfect but the file is totally blank. It has happened for only one file but need to know the reason.

View 14 Replies View Related

Visual C++ :: Reading CSV File - Show Values In List?

Dec 26, 2012

I have problem reading CSV file, i found many solutions but i still got one problem. I need to read CSV file and then these values show in List Control and here i have problem. Idk how to display it in List?

View 4 Replies View Related

Visual C++ :: Copying One Bmp File To Another Using Fstream - Access Violation Reading Location

Dec 31, 2014

I would like to copy one bmp file to another using plain fstream (none 3-rd party library). I've managed to come up with something but I keep getting error:

Unhandled exception at 0x504A3442 (msvcr120d.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0x00380000.

when i try to write the content of the bmp files not the header, namely error occurs in this line:

Code : ofs_differential.write((char*)&picture, (bfh_warm.bfSize - bfh_warm.bfOffBits));

Also i am not sure if i am doing it in a right way, meaning that even after solving this error i will copy the bmp file successfully.

Code:

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
struct BITMAPfileHEADER {
unsigned short bfType;

[code]....

View 3 Replies View Related

C :: Visual Studio 2012 - Writing Data Into TXT File / How To Stop Reading Char

Feb 23, 2013

I am using visual studio 2012.....in below code i m writing data in to a test.txt file but i dont know with which key file stop accepting char...i tried ctrl+z and ctrl+d but not working ....

Code:
#include<stdio.h>
#include<conio.h>
main(){
char ch;
FILE *ptr;

[Code] ....

View 7 Replies View Related

Visual C++ :: Crypt Input File Using ECIES

Nov 15, 2014

I am trying to make a basic crypting program, you simply input a file and it's crypted using ECIES.

So I use cryptopp, ( see the function : [URL] .....).

So I thought I just needed to open the files and crypt the content like that :

Code:
file = "lorem.txt"
std::ifstream if1s(file);
std::string content((std::istreambuf_iterator<char>(if1s)), std::istreambuf_iterator<char>());
if1s.close();

[Code] ....

Encrypt is a custom made function to make encryption simplier here is the header :

Code:
string encrypt(string message);

This works pretty well on text files but when I try to crypt a 1 mb image, the output is 0.5 kb which obviously can't be right, so I wonder if there is some specific way to crypt some files.

View 2 Replies View Related

C :: Word Length Statistics For A Sentence

Oct 25, 2014

Write a program that calculates statistics on word length for a sentence. The sentence isterminated by a ',' For each found length of a word the number of words of that length is printed. Only those lengths that are found in the input are printed. Only letters from a-z or A-Z are allowed to form words. Words are separated by a space. No punctuation characters other than ',' are allowed. If any other input character is recognized or the input is longer than 80 characters the program displays "NOT VALID" (see Hints).

Note, that in the case that no word is present in the input, nothing is printed.

% u6_stats

Enter a sentence: Bolt was expected to use the super bark.

Length 2: 1
Length 3: 3
Length 4: 2
Length 5: 1
Length 8: 1

% u6_stats

Enter a sentence: Something wasn't right.
NOT VALID

Thats what i've already done.

Code:
#include <stdio.h>
#include <conio.h>
void main() {
char s[100];
int numOfWords, lengthOfWord = 0;

[Code] ....

So, the problem is that if i inpute a text like"abc abcd abc abc" the result will be like

"length 3: 3 length 4: 1 length 3: 2".

So when the program already compared 1st (here 3) element with others, this element will not be comparing again, but i have the 3d element with same length, and it that case, the program compare it with remained elements and print 2. How can i rework my code, if i don't wont to compare already compared elements.

Second problem is that i need to get results from lowest length till highest.

View 2 Replies View Related

C++ :: Statistics Code - Comparing Two Columns Of Numbers?

Aug 17, 2014

I am wondering if there is some repository of c++ code for statistics comparing two columns of numbers? Statistics are so common now that it seems like with the oo concept of reusable code there should be allot of that floating around. Code that would accept two vectors and generate comparisons like pearson's correlation, root mean square error, mean absolute error, median absolute error, etc would be very useful.

I have looked around some and find some code examples, and other posts basically saying, "Google the algorithm and figure it out yourself." At this point, there should almost be stl classes like the ones for union(), intersection(), accumulate(), and other simpler math functions.

View 3 Replies View Related







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