Visual C++ :: Program That Get Data From DAT File
Mar 5, 2014
I am currently writing a program that grabs information from a .dat file. When I go to debut I get this error.
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
// function step 1 - declare the prototypes
void sort(int n); // catches an integer number from the call
void swap(string *p1, string *p2); //catches the location of data in ram
[Code] .....
View 5 Replies
ADVERTISEMENT
Jul 29, 2014
I am writing a program to display values from a data file as an image. But I can only get a blue screen. Here is a small program resembling my code. what I have missed? I only changed OnDraw function.
Code:
void CColorDisplayView::OnDraw(CDC* pDC) {
CColorDisplayDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CRect rect;
[code].....
View 10 Replies
View Related
Jan 11, 2014
I'm reading from a file the middle column of data (Volts) where my test file "AP.txt" is opened by my program. Here is a segment of the data:
time Volts dV
49552 -66.20183 -0.01556807
49553 -67.76025 -0.01556495
49554 -69.30704 -0.01533247
49555 -70.81799 -0.0148486
49556 -72.26774 -0.0141133
49557 -73.63226 -0.01315276
49558 -74.89141 -0.01201764
Since the calculation I performed gives me -71.77 Volts, I need to match this value to the time that this occurs closest to using my program, and output the time that this occurs at.
Here is my program so far:
int main()
{
std::ifstream inFile;
inFile.open("AP.txt");
ofstream results_file ("maxvaluewithinput.txt");
float TimeAtdVMax = 0;
float VoltsAtdVmax = 0;
[Code]...
If you're curious, this program isn't for homework. It's part of the independent learning on C++ I'm doing for a Master's Thesis; the program will eventually model the APD90 of a ventricular action potential.
View 10 Replies
View Related
Dec 11, 2013
I am writing a employee payroll program using structures. My program is running but its only showing some of the data.
HERES MY CODE
Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
#include <cstring>
using namespace std;
const int SZ = 20; // size of arrays to hold scores
struct payrollStruct {
[Code] ....
And it doesn't show anything from txt file
Code:
40.0 10.00 A1234 Jane Adams
50.0 10.00 L8765 Mary Lincoln
25.5 10.85 W7654 Martha Washington
52.0 15.75 A9876 John Adams
45.0 25.00 W1235 George Washington
[Code] .....
View 14 Replies
View Related
Feb 15, 2014
I'm not sure why my program isn't reading data from the dat file. I'm not sure if it's because I messed up my pointers, or I'm missing something. I know we usually use Infile >> blah >> blah >> blah; to get the data from the file, but my instructor showed an example that had the struct read it for you in this format and I could just call it with pointers.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <assert.h>
using namespace std;
using namespace System;
typedef int Integer;
[Code] ....
View 12 Replies
View Related
Sep 26, 2012
I'm trying to append data to a CFile using FILE* But when execute the application, it always give error saying "No such file or directory". I can actually see the file created but it just keep giving error "No such file or directory".
Is the file being lock or the file just created so it can not be find by fstream(FILE*)? or the file mode is wrong?
Below is the code:
[QUOTE]
void SaveDocument(CString strFile) {
CFile file;
if( !file.Open(strFile, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyNone)) {
CArchive ar(&file, CArchive::store);
// save now.
MyClass.Serialise(ar);
[Code]...
Attached is the printscreen of the FILE* pointer. the pointer is evaluated as bad pointer. Why the FILE* pointer not able point to the file being created?
View 7 Replies
View Related
Feb 26, 2013
Write a program that reads data from a file (use the attached data file). These data are a student name and 3 test scores. The program should calculate the average of the 3 test scores, and display the name, 3 test scores, and the average to the monitor.
Useful tips:
a) Include the following header files: iostream, fstream, iomanip, and string
b) The name of the data file is “datafile.txt”, you need to save the file in the same folder of the source file.
c) use the manipulators (setw, setprecision, setfill, showpoint, fixed) to format the average with 1 digits after decimal point as following.
d) Use character ‘ ’ for tab.
View 3 Replies
View Related
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
Sep 28, 2014
I'm new to programming and i'm trying to do a certain task. I want to use a for loop to read certain data from a txt file and print them to a console. I'm trying to read student names and their grades.
Something like
3 // 3 represents the number of students.
George 97
Sarah 70
Maya 88
The data may vary but it's always in this format.
View 14 Replies
View Related
May 14, 2013
How is it possible to store the related data of a program C++ into an external file (like as .txt) and retrieve it?
I want to write c++ program that can contain data members " id and phone"
like as
Code:
class profile {
private: int id,phone;
public:
void retriever() {
cout<<"Enter your ID: ";
cin>>id;
cout<<"Your Phone number is "<< phone;
};
}
avoiding formats in above class, purpose is to store data already in txt file with different id and phone numbers and it is to be retrieved by matching id number to txt file and viewing its related phone number.
View 1 Replies
View Related
Mar 14, 2013
How to write a C or C++ program that extracts certain numbers out of a section after the 4, 5 and 6 space.
For Example:
The output file will produce:
[ [1900 00 0 -2.000000 0.650000 0.006000 0.020000 2.274000 0.010000 54 0 0.7 10.8 1 0 0 0.000000 17.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 18];...
So I want to extract the numbers 0.650000, 0.006000, 0.020000 because those are the 4,5,6 space after [ [
Another problem I have is that the output file I showed will always being updated constantly for instance as follow:
[ [1900 00 0 -2.000000 0.650000 0.006000 0.020000 2.2054000 0.010000 10 0 0.7 10.8 1 0 0 0.000000 17.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 13];...
[ [1900 00 0 -1.000000 0.650000 0.006000 0.020000 2.694000 0.010000 9 0 0.7 10.8 1 0 0 0.000000 17.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 10];...
[ [1900 00 0 -2.000000 0.6023000 0.04000 0.050000 2.2454000 0.010000 5 0 0.7 10.8 1 0 0 0.000000 17.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 12];...
And it will keep updating like this and I want to update the previous numbers I extracted with now the new numbers after the 4,5, and 6 space.
So I have to write a code to let it know when it encounters [ [ start looking for the 4,5,6 space and get those numbers and once it reaches ;... that's the end of that section so re-look for the next section of numbers after the 4,5,6 space.
The file will be a text file or matlab file that is always being updated with these sections of numbers. Can I make this a #include<nameoffile.h> or does .h not work with a file that is always being updated.
View 2 Replies
View Related
Mar 26, 2013
I'm having issues trying to input data from a .txt file into my array program. The whole program takes the name, # of goals and assists, adds them together to get points, and then puts in a given + or - rating. The program works except for the data input.
Also, this is an alphabetical "Unsorted" list, but is there a way to order the list based on point value and be able to display that as well as a separate "Ordered" list?
#include <iostream>
#include <iomanip>
#include <fstream>
#define NUM_PLAY 30
using namespace std;
int buildArrays(int[], int[], int[]);
void printArrays(string[], int[], int[], int[], int);
[Code]...
And this is the .txt file. Order is Players Name, Goals, Assists, Plus/Minus rating. The points are added when points = goals + assists (Should be in the main coding above).
Bryan_Bickell 2 5 +2
Brandon_Bollig 0 0 0
Dave_Bolland 4 2 -1
Sheldon_Brookbank 0 0 -1
Daniel_Carcillo 0 1 +3
[Code]...
View 5 Replies
View Related
Jul 18, 2013
I am working on a project that uses a web service to extract a PNG image from a web server and save it on a local machine. It's done via a system call. I can get the output of the system call to a FILE but it appears to be losing data, most notably the PNG chunk names (IHDR/PLTE/IDAT/IEND, notably). (Unfortunately piping the output to an exterior file does not work through a system call.) The end result is ~6KB smaller than the file I am intending to retrieve.
This is the code I'm using (adapted from other material I found via searches here):
ofstream png;
png.open(/*outputfile*/, ios::binary);
FILE* fp = _popen(/*SYSTEMCALL*/, "rb");
string responseString;
if(fp != NULL) {
char a[100];
while(!feof(fp)) {
fgets(a, 100, fp);
responseString += a;
}
}
_pclose(fp);
png << responseString;
Am I missing something or just doing it wrong?
View 11 Replies
View Related
Feb 11, 2014
I have written a CFD program that final results store at several 2D arrays. For instance, temperature of a square plate. For every point of plate i and j (i,j), I have a temperature amount. On the other hand, these temperatures change by time.
theSpace.TheCells[i, j,0].Temperature
I would like to save these data into an excel file and each sheet contains data for specific time (for example, an excel file with 50 sheets that cell number shows the coordinate of a point and the value in it is the temperature and next time step data's will be in the next sheet of current workbook )
I was thinking my code should be something like the following note, but it doesn't work:
// Implement time loop
int counter = 0;
for (int step= 1; step<= MaxSteps; step++) {
// call Excel output method
ExportData(ResultsArray,step,nx,ny);
[Code] ....
View 7 Replies
View Related
Dec 22, 2014
I'm trying to make a Quiz program based on C++'s Data File Handling capablities. I've attached the code in .txt file and I wonder why I'm getting the error identifier bScience cannot have a type qualifier?
Attached Files QuizPro.txt (9.6 KB)
View 7 Replies
View Related
Nov 11, 2013
i tring to write a employee payroll code with functions and read data from the txt. file and also bubble sort that sorts and displays starting from employees last name and calculations.
//txt file//
Hours Pay rate empID first name last name
40.0 10.00 A1234 Jane Adams
50.0 10.00 L8765 Mary Lincoln
25.5 10.85 W7654 Martha Washington
52.0 15.75 A9876 John Adams
45.0 25.00 W1235 George Washington
40.25 55.00 L9087 Abraham Lincoln
30.0 9.75 T9876 William Tell
42.5 12.50 M7654 Missy Muffett
30.0 10.00 P8765 Peter Piper
and here is my code
Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;
void tellUser();
[Code] .....
here are the errors the are giving
Code:
payroll.cpp: In function "int bubbleSort()":
payroll.cpp:52:8: error: "lastpos" was not declared in this scope
payroll.cpp:52:18: error: "numemp" was not declared in this scope
payroll.cpp:56:10: error: "swapmade" was not declared in this scope
payroll.cpp:57:16: error: "i" was not declared in this scope
[Code] ....
View 14 Replies
View Related
Mar 14, 2013
Objective of this program is to read binary data from a file and print it.
Code:
#include <stdio.h>
void readFile(void);
int main(){
readFile();
return 0;
[Code] .....
But When I Run This Code First It Print "Error." Then Rest Of The File.Say In My File I Have "I AM HUMAN", It Prints "Error. HUMAN"!!
I Cant Figure Out Whats Wrong In The readFile() Function.It seems right to me.
View 4 Replies
View Related
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
Oct 14, 2014
You are to write a C program that grades a true-false quiz. The quiz data will be available in a text file; here is an example:
Quiz #8 (09/22/14) (corrected version)
TTFTTFTFTF
0080 TTFTTFTFTF
0340 TTFTFFTFTF
The first line in the data file is a comment that you may assume can be up to 80 charac- ters long; it cannot be blank. The second line contains the answer key for the 10-question true-false quiz. The following lines in the data file contain a student's id number in column 1 followed by their answers for the quiz in column 2. A 0 (zero) on a line by itself indicates that there are no more students to process.
Write a program that first reads in (from standard input; more on this in a moment) the comment line and answer key as strings followed by each student's data. Store the student's id numbers in an array. You are to "grade" each student's quiz using the key provided fol- lowed by recording their scores (in a second array) in order to be able to print them out later. You do not need to use an array of strings or characters in your program. Write your program allowing for up to 100 students, and you may assume that at least 1 student will have taken the quiz.
You should create test data text files and provide the data to your program using redirection from the command line (see the sample run below). Your program should output the number of students who took the quiz, the average score, the best score, and a table showing each student's id, score, and grade. The formatting, spacing, and labels in your output should 1 match the sample run below exactly.
Your program should determine each student's grade as follows: if the score is equal to the best score b or b−1, give an A. If it is b−2, award a B. Give C's for any score that is equal to b−3 or b−4, a D for b−5 and an F for all others.
Alright So I'm just stuck at comparing the key answer with student answer here is my code comparing one student's answer with the answer key . is that right ?? One more thing for some reason when i try to print answer[0] the result is nothing why is that
Code:
#include<stdio.h>
int main(void) {
char comment[80];
char answer [10];
char studentans [10];
int n=0,i=0,x=0;
int ID[10];
[Code] .....
View 1 Replies
View Related
Dec 4, 2013
I have a program that stores health information the user inputs, one person at a time. The program works perfectly with the exception of storing the data...I need to open a file and read what health data it has in it already, if any, but store the new changes, and appended data to the array of structures, to the data in memory. All of the information is only saved back in the file once the program terminates. I'm not sure how to go about doing this, so I am also not sure what to put in the function for "Save and Exit" that the user can choose in order to exit the program.
Code:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct strdatabase
{
char first[20];
char last[20];
char gender[2];
[Code]...
I tried playing around with this bit of code, but I'm not sure if I'm even on the right track.
Code:
FILE *fp;
fp = fopen ("students.txt","rb"); fseek(fp, 0, SEEK_END);
long pos = ftell(fp);
fseek(fp, 0, SEEK_SET);
char *bytes = malloc(pos);
fread(bytes, pos, 1, fp);
fclose(fp);
View 9 Replies
View Related
Nov 12, 2014
I have been asked to create a program that accesses an inventory file done in excel, look for a alpha-numeric code, which will be inputed by the user, and return to the user informations related to the position of that code, and informations related to the header of the column in which the code resides.
An example of the function I need the program to perform would be:
User inputs: 1429-R1
And the program returns: Marco's 6A, 8/21/2014, 3/7/2014.
using the following example of file:
Marco's 6A
Assessment 8/21/14 3/7/14
1584-R1 1584-R1 1584-R1
1461-2R1 1461-2R1 1461-2R1
1429-R1 1429-R1 1429-R1
View 1 Replies
View Related
Oct 28, 2014
I am trying to write my files to another subfolder . Below is my program.
Code:
cat th6.c
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#define SIZE 8
#define NUMELM 8
[Code] ....
I observe my filename along with directory as text in the new file created in sublfolder. This is output.
[cporgs/apue/threads]: mkdir first
[cporgs/apue/threads]: ./a.out test.txt first
test.txt -- first/test.txt
dfdfdfdfdfdfdf-14
dfdfdfdfdfdfdf-14
in thread test.txt first
[cporgs/apue/threads]: cat first/test.txt
dfdfdfdfdfdfdffirst/test.txt
[cporgs/apue/threads]: cat test.txt
dfdfdfdfdfdfdf
I could not able to get from where this filename and folder is getting added.
View 4 Replies
View Related
Dec 10, 2014
I'm trying to get the program to read from a file of 15 scores. 10 are quizzes 5 are exams. I want my program to read from the input file the first name "or" last name and if the user puts a different name, the program Gives off an error screen message
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
const int NUM_STUDENTS = 20;
const int NUM_QUIZZES = 10;
const int NUM_EXAMS = 5;
[code]....
View 14 Replies
View Related
Mar 10, 2014
I am writing a program that grabs information from a .dat file. I have the code all structured up, but I get these 2 errors that does not make any sense to me on how to fix the program.
errors (2):
Code:
Error1error LNK2019: unresolved external symbol "void __cdecl swap(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> > *)"
[Code] ....
Error2error LNK1120: 1 unresolved externalsC:UsersMomDesktopDriveQuarter 2C++ProjectsDynamicDeptPayrollDebugDynamicDeptPayroll.exeDynamicDeptPayroll
.dat file contents:
Code:
Fogarty Bob 1 40 10.25
Smith John 2 38 8.72
Jones Mary 2 28 6.25
Arrmen William 1 15 8.22
Lavey Betty 1 32 15.00
source contents:
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//PROTOTYPES
void sort(int n);
void swap(string *p1, string *p2);
[Code] ....
View 2 Replies
View Related
Sep 29, 2013
How to write a programme that take strings from file and push it into the stack with number of each sting string before it and later clean the stack?
View 6 Replies
View Related
Feb 6, 2014
I am wanting to be able to add as many different instances of data, while the user has not stated 'n', but then it only ever writes back to the screen the input for the last set of data. Where as I want to display back to the screen all the data that has been entered.
Code:
#include <iostream>
#include <string>
/*Function Declaration*/
void createItem();
void returnItem();
//Items structure
[code]...
View 6 Replies
View Related