C++ :: Getting A File From Designated Location / Grab Value And Make Calculations

Oct 30, 2013

My project is to get a file from a designated location in my computer and not just read, but grab the values from the user and make a count, sum, and average calculation of the numbers in my code. I am using the fstream library and I am trying I did do it, I got the values and calcualated them, however I want the values to be accessed from maybe my desktop or my drive, I want to know how to manipulate my code to get a path like C:UserDesktop and maybe executed from the path input or given. I dont know if this is possible, or easy to do. ALso I did copy some of this code from my teachers examples and I dont know exatly why the variables have to be initilized at zero, and I would like to know a little more on the Bitwise right shift breaker used in line 20 something.

Here is my code below.

#include <iostream>//For avergae functionality
#include <fstream>//For the file commands, such as ifstream and the Bitwise right breakers(<< and >>).
#include <iomanip> // To control the amount of decimals in my results desired.
using namespace std;
int main () {
int aNumber=0; //Initilized at zero because of Stack Overflow:

[Code] .....

View 2 Replies


ADVERTISEMENT

C :: Cache Optimizations / Make Multiplication And Calculations Faster?

Jan 30, 2014

I have a 125X125 array, each element is 55 bits. The cache line for the CPU ( Cortex A9) is 32 bits. Is there anyway to do optimizations, like loop tiling that would make multiplication and calculations faster?

View 5 Replies View Related

C# :: Detecting CD-ROM Drive And Grab Filepath Of Only CSV File

Jul 8, 2014

I would like the user to insert a CD into their computer and click on an button on my application that allows them to read the CD-ROM and find a specific file type, e.g. csv, and then grab the info in the csv file.

I already have my StreamReader setup grabbing a filepath.

Now I am just wondering...how do I detect the CD-ROM and how do I grab the filepath of the only CSV file on the CD-ROM?

What's behind detecting a CD-ROM and grabbing a specific file type from a CD-ROM?

I heard about DriveInfo

However, that only allows me to detect a drive but not look at it's contents.

View 14 Replies View Related

Visual C++ :: Grab Special Lines From A File

Nov 28, 2012

I have a file that contain different content, some lines inside that file looks like that :

Time : xx:xx:xx
Time : xx:xx:xx

So, I want to grab lines that start with "Time : " and put them inside a list<string> for later use. I am using windows so I don't know if the newline character is '
' or '
' also I don't want my grabed line contain any special character.

I have this code, but didn't work well because some special characters remain inside the string.

Code:

string buf;
list<string> ls;
ifstream read("test.txt", ios_base::binary);
while(!read.eof())
{
getline(read,buf,'

[Code]...

View 1 Replies View Related

C++ :: Text Game - How To Make Player Go Back To Previous Location

Mar 19, 2013

I have started making a text adventure game.

if (Choice == 2) {
cout << "" << endl << "You follow the light to the end of the hallway, you find your self in a room" << endl
<< "with natural light coming from a hole in the ceiling." << endl << "" << endl << "You hear the door you just came through, slam behind you!" << endl << "" << endl
<< "There are three possible directions." << endl << "" << endl << "Do you:" << endl << "" << endl << "1) Go forward" << endl << "" << endl << "2) Go left" << endl

[Code] .....

Ignore the if (Choice == 2) at the beginning, that's linked to some previous code.

I want to make the player go back to the first bit of text but i'm not sure how to do this if they keep choosing to go back and forth from one location.

I first thought of doing it by just putting the text back in after they have chosen the option, but I can't do this infinite times.

View 5 Replies View Related

C++ :: When Make Grid In DirectX It Says Access Violation Writing Location

Aug 9, 2014

I am trying to make a grid in DirectX, but I keep getting the error "Access violation writing location" for some reason.

This is my code for defining the grid:

void CDirectXFramework::DefineGrid(int Rows, int Cols, float dx, float dz, const D3DXVECTOR3& center) {
/* precalculations */
int CellRows = Rows - 1;
int CellCols = Cols - 1;
float width = (float)CellCols * dx;

[Code]...

What does it look like the problem might be?

btw, the values I am using are:

Rows = 100;
Cols = 100;
dx = 1.0f;
dz = 1.0f;
center = D3DXVECTOR3(0.0f, 0.0f, 0.0f);

I found that the program works when using these values for the rows and columns:

Rows = 2;
Cols = 2;

Using any other value gives the error mentioned above. It displays a small flat surface where I want it to, but I am trying to have a large enough surface to use as a ground (like 100 x 100).

View 5 Replies View Related

C++ :: Calculations From Text File?

Mar 31, 2014

I have a text file that contains values as follows:

2013 05 27 15 52 02.049824 231.401 0.022 49.738
2013 05 27 15 52 02.668822 229.814 0.019 49.738
2013 05 27 15 52 03.283705 228.528 2.599 49.726
2013 05 27 15 52 03.898469 230.140 2.576 49.751

Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? The file data contains over 50 thousand lines in the format mentioned above.

View 5 Replies View Related

C++ :: Getting Multiple Objects To Move Randomly At A Designated Number Of Intervals

Jan 9, 2015

I have a piece of code which gets multiple objects to move randomly at a designated number of intervals. I want to create a function which calculates the distance between each pair of points after that number of steps. so the distance between object 1 and object 2, object 1 and object 3, ..., object 1 and object N. then object 2 and object 3, object 2 and object 4, ..., object 2 and object N. then then object 3 and object 4, object 3 and object 5, ..., object 3 and object N and so on until the distance between all the pairs of points have been calculated.

#include <ctime>
#include <cstdlib>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<fstream>
#include<vector>

using namespace std;

double dist(int a, int b);
int X(int x1, int x2);
int Y(int y1, int y1);

[Code] ....

View 4 Replies View Related

C++ :: Display Lines Between User Designated Points With Circles At Each Point

Jan 22, 2015

I'm trying to write a code that displays lines between user designated points with circles at each point, but I can't get the lines to display! I'm at a loss on what to do and need fresh eyes on the subject.

#include <iostream>
#include "graph1.h"
using namespace std;
//Function Prototypes Follow
void getNoPoints(int* no_points);
void getPoints(int* x, int* y,int no_points);
void drawPolyLine(int* x, int* y, int no_points,int objects[]);

[Code] ....

I imagine the error is in this segment:

int i=0;
for (i = 0; i < no_points;) {
objects[i] = drawLine(x[i],y[i],x[++i],y[++i],1);
setColor(objects[i],255,255,0);
}

View 1 Replies View Related

Visual C++ :: Grab Screen(s) And Invert Their Brightness

Jan 15, 2014

I have a visual impairment that makes it very hard for me to use the standard dark text on white background themes. I use High Contrast but many apps don't query the system for colors (I.E. aren't theme-aware) and consequently display pale or dark text on a white background regarding of the theme selected.

There is a product called ZoomText that allows for inverting the brightness of everything being displayed. I just use a normal theme, let all apps display naturally, and then invert the entire screens brightness.

But ZoomText doesn't support multiple monitors. And it does a lot more than I need. And it hogs the CPU. And it costs a lot.

Looking for some of the APIs that I need to capture the bitmaps for all monitors, invert the brightness of all pixels, and refresh the display contexts. And make that happen so smoothly that it appears like there is nothing going on behind the scenes. (DirectX, OpenGL, ???)

View 4 Replies View Related

C :: GCC Does Not Recognize Lib Location - No Such File Or Directory

Aug 19, 2013

I have my libraries in ../../lib location

and when i try to compile :

gcc -O9 -I ../../include/ -L ../../lib/ -o test test.c thr.o -lm -lthread

I get :

gcc: error: thr.o: No such file or directory

obviously the problem is the library path location but my obj is there

ls -al ../../lib/ | grep thr.o
-rw-rw-r-- 1 xxxxxx xxxxxx 23544 Aug 12 23:03 thr.o

????

View 2 Replies View Related

C++ :: Write A Location In A Binary File

Jan 3, 2013

I have a std::vector of short ints that I need to write to a specific location in a binary file (without using .NET code). To that end, I wrote up this code:

Code:
ofstream fileStream (filePathString, ios::out | ios::binary);
int curPos = 2821;
fileStream.seekp(curPos);
int iter = 0;
while (iter < 1024*1024){
char bytesToWrite[2];
//Low byte
bytesToWrite[0] = LOBYTE(dataVector[iter]);

[Code]...

The code runs without crashing, but when I look at the file afterwards in a hex editor, every byte (even those outside the range I thought I was writing to) are replaced with 00. I suspect I'm missing something in my understanding of file streams. Did I write that code correctly? Seekp does move the pointer over the next byte to be overwritten, yes? Am I getting a memory leak somewhere?

View 5 Replies View Related

C/C++ :: How To Open Text File From A Specific Location

Feb 2, 2014

I'm having trouble opening a file from a specific location.

#include "maidcafe.h"
....
char directory[80] = {"C:UsersPublicDocumentsAnime NotesTransaction"};
char code[20];
printf("Enter file name");
gets(code);
strcat(directory,code);
system("start "" %s",directory);    

i thought this would work, but it didn't xD. I got an error

View 3 Replies View Related

C++ :: Reading GLOBE File - Access Violation Writing Location 0x00000001

Jan 15, 2015

I am working Visual C++ 2012. I am trying to read a GLOBE file using the following code.

#include "stdafx.h"
#include "iostream"
#include <stdio.h>
#include "stdlib.h"
#include "string.h"
#include "cmath"
#include <errno.h>
using namespace std;
/* Conversion useful */

[Code] ....

I am getting the error in the if condition (bold).

View 12 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/C++ :: Calculations From Textfile?

Mar 31, 2014

I have a text file that contains values as follows:
2013 05 27 15 52 02.049824 231.401 0.022 49.738
2013 05 27 15 52 02.668822 229.814 0.019 49.738
2013 05 27 15 52 03.283705 228.528 2.599 49.726
2013 05 27 15 52 03.898469 230.140 2.576 49.751

Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? I also have to use at least one integration method. The file data contains over 50 thousand lines in the format mentioned above.

View 11 Replies View Related

C++ :: Calculations From Text Files?

Mar 31, 2014

I have a text file that contains values as follows:

2013 05 27 15 52 02.049824 231.401 0.022 49.738 2013 05 27 15 52 02.668822 229.814 0.019 49.738 2013 05 27 15 52 03.283705 228.528 2.599 49.726 2013 05 27 15 52 03.898469 230.140 2.576 49.751
Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? I also need to include at least one numerical integration technique. The file data contains over 50 thousand lines in the format mentioned above.

View 2 Replies View Related

C++ :: Calculations Are Done Correctly But Showing Zero

Nov 26, 2013

#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;

[Code] ....

View 1 Replies View Related

C/C++ :: Adding Calculations To BMI Calculator

Oct 8, 2014

I have to enhance my BMI program to tell whether the person is at optimal weight, under weight, or overweight and I cannot find the correct calculation. Here is the code I have so far that works for calculating the BMI.

namespace Body_Mass_Index {
public partial class BMI_HW : Form {
public BMI_HW() {
InitializeComponent();

[Code] ....

View 14 Replies View Related

C/C++ :: Overtime And Payroll Calculations

Apr 11, 2014

When you execute my code you'll notice the regular pay for the first example will calculate to $500 when it is only supposed to calculate to $400. I'm also having a problem adding up the totals of the regular pay and overtime pay to get a total payroll which is displayed in one cout statement. 95% of my code is correct, I'm just having these two issues. To make it more clear hear is my assignment:

The regular working hour for an employee is 40 hours a week. Sometimes employees work over time. When the employee works 40 or less hours, the regular pay is calculated as number of hours worked times the hourly rate. When the employee works over time i.e. beyond 40 hours then the employee's pay has two components a) regular pay (40 hours X hourly rate), and 2) overtime pay (the overtime hours beyond 40 X time and half of the hourly rate).

void compute(incomeInfo *ptrI, int count) {                                                
    for (int i = 0; i<count; i++)  
    if (ptrI->hours <= 40) {
        ptrI->regPay = ptrI->hours * ptrI->hRate;
        ptrI++;

[Code] ....

View 1 Replies View Related

C++ :: Timer With Non-return Calculations

Dec 25, 2013

My game runs in a while loop, as you can see in the code below. I need a timer, which won't stop this loop or freeze it, but it will wait, until timer is over and executes code without interfering with the while or for loop.

Code:

Code:
#include <iostream>
#include <iomanip>
#include <windows.h>
#include <ctime>
using namespace std;
char *map[25][25];

[Code] ....

View 1 Replies View Related

C/C++ :: Menu Driven Complex Calculations

Mar 18, 2015

//complxCalc.cpp//

#include "complx.h"
using namespace std;
ifstream infile ("in.dat");
int main() {
int i = 0;
complx tempComplx;
double d = 4.5;

[Code] ....

//in.dat//
(4,4) (6,7) (2.5, 9.3) (3,8.4) (13, 26.5) (2.2, 3.4)

My plan is to make this a menu driven program, I have already got the program to give the answers but now I want it to give the user choices as well. The first step in this project is to add a menu to the program. The first menu the user sees should ask the user if the program will be taking input from a file or from the user directly via the keyboard. Regardless of option chosen, the user should then be prompted to specify whether a multiplication,subtraction or addition operation should be performed.

If the user originally chose the file input method then the program should proceed to display to the screen the results of those operations on each pair of data elements in the file and terminate. If the user chose to input via the keyboard then the user should be prompted to input the two numbers, perform the operation on those two numbers and display the results to the screen and ask the user which mathematical operation they would like to do next and continue in this manner until the user chooses to exit the program via a menu option. Fortunately the only file that needs to be edited are in.dat and complxcalc.cpp files.

View 1 Replies View Related

C++ :: Writing Calculations For Unknown Amount Of Students?

Jun 27, 2014

I need to create a program that continuously records data until the user enters '0'

The data that I read in is the student's last name, the year of the student (1-4), the major, the gpa, and the advisors name. I then need to print out how many students are in each year (1-4), the number of students each advisor has, the average gpa for each major, and so on. This is what I have, but I am stuck and think that I might be headed the wrong direction because the only thing working is the loop (not my gpa test calc).

//This program displays information pertaining to students
#include <iostream>
#include <string>
using namespace std;
int main () {
int studYear;
double average, studGpa;
string studName, studMajor, studAdvisor, complete;

[code]....

View 2 Replies View Related

C/C++ :: Using Values From Distance Array In Function To Be Used For Calculations

Mar 30, 2014

I know that the issue is around the array distance being of type double in the function get distance of type double. My question is how do i get around using the values from the distance array in the function to be used for calculations.

#include <stdio.h>/* initialization of preprocessor directives*/
#include <stdlib.h>
#include <math.h> /*preprocessor directive in order to use sqrt function*/
int calcSecondsvar(int,int,int ,double);
double getdistance(double,double,int,int,int);

[Code] ....

I forgot to mention that it keeps giving me the error cannot convert from 'double[8] to 'double' ....

View 2 Replies View Related

C/C++ :: Employee Payroll Calculations Program For A Class

Sep 30, 2013

getting output from my code when I compile, the codeblocks ide doesnt show any errors it just doesn't give me any out put when I compile?

Here is my code:

#include <iostream>
#include <string>
#include <iomanip>  
using namespace std;  
//
//CLASS DECLARATION SECTION

[code].....

View 1 Replies View Related

C :: How To Make Text File Of Bits Stored In AVI / Binary File

Feb 5, 2014

I need to create a program which could create text files of the bits stored in avi file/binary file. My first requirement is to show 0s and 1s in the text representation . My second requirement is to create an avi file from this text file. I have tried few codings but either they give me error or they not playing the reconverted binary files.

View 6 Replies View Related







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