C++ :: Object Data Not Updating Correctly

Dec 14, 2013

I am writing a program that manages a group of tool bins. This group is handled as an object that is an array of two element structures called InvBin. I initialize the bins with data from a file which contains the descriptions and initial quantities. I also have functions to add or subtract items from a bin and a function to display a report of the description and quantity of all of the bins.

The add and remove functions work correctly based on the cout statement in the functions, however when I display the report, it displays the initial quantity instead of the new quantity. In addition, when I use the add and remove functions again on the same bin, they use the initial quantity.

These are the add and remove functions and the report function from the main program.

Code:
//Adds an item to a bin
void addItem(HANDLE screen, BinManager tools, int &count) {
int binNum;
int addNum;
system("cls");

[Code].....

View 2 Replies


ADVERTISEMENT

C :: Updating Specific Data In The File

Mar 17, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define MAX 200

[Code] ....

Inside of my studentinfo.txt file

Code:
Jnh Has 2353325 23 56 72 34 67 22 46 42 5 23 56 23
Daniel Laurent 6744590 10 20 30 40 50 60 70 80 90 100 40 50

This code is working totally fine. Right now, I'm trying to update a specific data from the student info. Let's say I'm trying to update my student number of Daniel. So, in this case, I want to replace 6744590 to some other student number. I think I have to use fseek() or rewind() and use fputs() but, I don't know how I should decide where to look.

View 8 Replies View Related

C++ :: Program To Extract Numbers From A File That Is Always Updating With New Data

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

C Sharp :: Updating String Values Into Custom Data Xml Field

Feb 23, 2014

I have a variable named Authors. Sometimes I will insert one author into the database, sometimes more than one author will be inserted into the database.

The page that performs the update is a .cs page. Here is the layout:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;

[Code]....

This definitely works for updating one author's name:

if (old.Author != Author) RequestItem.UpdateField(LibraryDocID, Editor, "Author", Author);    

I just can not nail down how to insert a string of author's names.

View 2 Replies View Related

C++ :: Reading All Data For Object

Apr 15, 2014

All i need is to create a "read" function to read all the data for a Player Object.

So Far i made a display function to display all the data for the "Player" object, but i don't know how to make a read function.

Here is my program:

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include "player.h"

[Code] .....

View 3 Replies View Related

C++ :: Object That Contains 2 Types Of Data

May 24, 2014

How do you create an object (like in the title) something more simple than a struct? I wanna know that cuz I'm writing a function that could return a boolean and an integer at the same time.

View 2 Replies View Related

C# :: Using The Sage Data Object?

Jan 29, 2015

I've downloaded a Sage 50 2014 data object and added a reference to it in my project. I'm able to connect to the Sage Account package using:

SDOEngine sdoEngine = new SDOEngine();
WorkSpace workSpace = sdoEngine.Workspaces.Add("MyCompany Limited");
try

[Code].....

View 4 Replies View Related

C++ :: Copying Data Allocated By New Object

Dec 21, 2013

I have an abstract class Base, with derived classes Derived1, Derived2, etc. I don't know how many there are. So, I have declared an object of Derived like so:

Base* der1 = new Derived1(/* constructor details */);

That gets passed to a function, which modified the data contained by this pointer. However, I need to keep the data from the object, which means that I need to copy the data somehow. The problem is, this copying needs to be done within the function, due to the requirements of the program. I do not know what type the object is, This function will need to reset this data potentially hundreds of times, so I can't just provide lots of objects, as either the function will run out of objects to call or I will run out of space in memory.

How would I create a copy of this, so that I would be modifying a temporary object that could be deleted and I would keep the data that I started with?

View 4 Replies View Related

C++ :: One Object Accessing Private Data Of Other?

Feb 26, 2012

Basically, I've got one object which has to access private data in another object... and can't.

Here's the specifics: I'm writing a little war game program where players deploy units (soldiers, tanks, planes, etc.) onto a gameboard. Players and Units are modeled as objects:

Code:
class GameUnit {
public:
string GetName() {return Name;}
protected:
string Name;
};
class Player {

[Code] ....

Here's the problem: In the above code, Player's ListUnits() function doesn't work because Player can't access GameUnit's GetName() function.

Specifically, here's the compiler's error message:

Code:
In file included from Main.cpp:18:
Player.h: In member function 'void Player::ListUnits()':
Player.h:47: error: 'GetName' undeclared (first use this function)
Player.h:47: error: (Each undeclared identifier is reported only once for each function it appears in.)

I've tested enough to realize that the problem is the GameUnit::GetName() function is a public function within the GameUnit object. Why can't a Player call this function? Making both friend classes of each other doesn't work.

View 3 Replies View Related

C++ :: How Could Object Access Its Private Data Members From Outside

Nov 12, 2013

How does an object access its private data members in copy constructor.

The relevant part of the code: Code: C::C(const C &obj)
{
x = obj.x;
y = obj.y;
}

Normally the object1 called "obj" cannot access its private data members outside. But in this situation it can access. How can it be explained?

Here are the complete code:

Code:
#include <iostream>
using namespace std;
class C{
public:
C(int,int);
C(const C &);

[Code] .....

View 7 Replies View Related

C++ :: Size Of Object If There Is No Data Member In Class

Aug 20, 2013

What is the size of object in c++ , if there is no data member in the class ?

View 3 Replies View Related

C/C++ :: Object Of Arrays As A Private Data Member?

Mar 19, 2014

#include <iostream>
#include <string>
using namespace std;
class book {
private:
string bookname;
double bookprice;
public:
book(string k="calculus",double b=25.5)
{ bookname=k;
bookprice=b;
}

View 2 Replies View Related

Visual C++ :: Object As Data Member Having Error

Sep 20, 2012

class CPop {
CBSVector<CTour> pop;
CBSVector<double> probability;
int popsize;
double TotalFitness;
CTour Elite;
CTspGAParams GAParameters;
}

error C2059: syntax error : 'constant'
error C2238: unexpected token(s) preceding ';'

I don't know y these errors, it runs fine in simple c++ environment

View 14 Replies View Related

C++ :: Reading File With Delimiter - Storing Data To Object

Dec 5, 2014

I am trying to read a file use the data line by line to create into an object. The current file I have is like this and the code reading the file will be found below.

1223 Fake1 Name1 60 70 80 24 89 add1 Male
1224 Fake2 Name2 61 70 81 80 24 add2 Male
1225 Fake3 Name3 63 70 82 80 89 add3 Male
1226 Fake4 Name4 63 70 83 80 88 add4 Male

The problem I am having is that I need to put delimiters in the file so that a person can have more than one name and also the address can now hold multiple strings until the delimiter.

I would like to change my file to this;

1223 : Fake1 Name1 : 60 : 70 : 80 : 24 :89 : This will be address1 : Male
1224 : Fake2 Name2 : 61 : 70 : 81 : 80 :24 : This will be address2 : Male
1225 : Fake3 Name3 : 63 : 70 : 82 : 80 :89 : This will be address3 : Male
1226 : Fake4 Name4 : 63 : 70 : 83 : 80 :88 : This will be address4 : Male

How can I update the code below so that it can use the delimiters to create an object?

void loadFile(Person people[], int* i) {
ifstream infile("people2.txt");
if ( !infile.is_open()) {
// The file could not be opened
cout << "Error";

[Code] .....

View 5 Replies View Related

C++ :: Unable To Modify Object Data In Linked List

Apr 14, 2014

I'm having a problem trying to modify my patient's data. It seems to work, but once the block of code ends it does not save to the linked list.

Problem located in case M.

linked list template header: [URL] ...
patient header: [URL] ...
patient implementation: [URL] ...

#include <iostream>
#include "listTemplate.h"
#include "PatientRecord.h"
using namespace std;
char menu() {
char input

[Code]...

View 1 Replies View Related

C/C++ :: How To Increment Data Members Of Dynamically Created Object

Jun 26, 2012

I am to first increment data members of object that has not created dynamically (i have done with this part),now i have created object dynamically and how to increment its data which i have passed as argument as:

obj3 = new manage(35 , 36)

View 4 Replies View Related

C++ :: Input Data Of Object From User And Then Insert It In Linked List

May 16, 2013

Error:
--------------------Configuration: nc - Win32 Debug--------------------
Compiling...
cv.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/nc.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

nc.exe - 2 error(s), 0 warning(s)

Compiles with 0 error but on running 2 Errors appear.

I'm Inputting data of an object from user and then inserting it in the link list.

#include <iostream>
//#include <fstream>
using namespace std;
#define LEN 100
////////////////////////////////////////////////////////////////////////////////////////////////////
class employee{

[Code] ....

View 1 Replies View Related

C++ :: String Stream Object And Text File Data Access

Jan 21, 2014

I have two puzzling issues I am dealing with.

Issue 1: I am using a stringstream object in a block of my program that needs to be visited repeatedly depending on a user's selection from a menu. I want the contents of this stringstream object to be cleared any time control gets to this part of the program. I have tried the clear and flush functions to no avail.

Issue 2: I am reading data from a source text file that would be regularly changed during the course of program run. After the program run is over, I am supposed to save the results(which is basically the source text file AND all updates) in a destination file. This destination file would then serve as the source file when next the program is run. In other words, I want a scenario where my results overwrite the original contents of the source file; implying that my source and destination files are now one, pretty much. How can I do this?

View 7 Replies View Related

C# :: SQL Update Not Updating But Can Add - No Errors

Feb 1, 2015

I am currently just trying to update a record in a SQL database.I can add a record and delete a record just fine but when I go to update I get no errors but it just doesn't update.

Here is what I have and done coding for hours trial and error

private void btnAddProd_Click(object sender, RoutedEventArgs e)
{//validate method // product = new Product(txtProductName.Text, Convert.ToDecimal(txtProductCost.Text), txtProductType.Text);
product = new Product();
MakeProduct(product);
if(modify) {
Product theOneAndOnly = new Product();

[Code] ....

View 1 Replies View Related

C/C++ :: Updating Values In Dat File

Nov 9, 2014

The file name is "movie.dat" and currently i was able to save data into the file in this order:

[movie_code] [movie_dur] [movie_title] [movie_rating] [movie_dir] [movie_genre] [movie_status]

[12345] [120] [Movie] [PG13] [Director] [Comedy] [Active]

I want to search for the "movie_code" and change the [movie_status] from Active to Inactive.

So lets say for example i have a movie code 12345 saved in my movie file. I want to change the value from "Active" to "Inactive"for argument sake.

This is the code i was trying to do it with:

FILE *movie_fp;
movie_fp = fopen("movie.dat", "r+b");
int m_code;
MOVIE movie_data;
printf("*** Welcome to the movie updater! ***
");
if(movie_fp != NULL){

[Code] ...

View 2 Replies View Related

Visual C++ :: Updating To New Windows SDK?

Apr 27, 2013

I've just integrated the Windows SDK V7.0A into my VS2005 application, and I'm getting the dreaded "Application configuration error" when I try to run it on an XP machine.

It runs fine on the development machine, and some customer machines (Win7 and Win8), but will not run on XP due to missing/incorrect version dlls.

I've rebuilt all my libraries, but still no joy.

So, my first question is - If I upgrade the Windows SDK to V7.0A, do I also need to use MFC 10 and msvcrt10, or can I stick with MFC 8?

The next question is, how do I find out which dlls are missing, and which libraries or other dlls are requesting the missing versions?

View 11 Replies View Related

C++ :: Updating Global Pointer In Tree

Jul 16, 2013

I am having trouble updating my global pointer in the following code,

Code:
#include <iostream>
using namespace std;

struct RB{
RB()=default;
RB(int clr):color(clr) { }
int color;

[Code] ....

The problem is, at line where I compar y==Tnil, It is evaluating to false at the first insert. But It should be true. again, after ending the function, T again becomes equal Tnil, as a result , none of the is being inserted.

View 2 Replies View Related

C :: Cannot Get Out Of Loop - Stuck With Updating Variables

Jul 18, 2013

Code:
#include<stdlib.h>#include<stdio.h>
#include<unistd.h>
#include<math.h>
int main(void)
{
double N, NG, LG, epsilon, root; // setting all variables to type double

[Code] .....

The goal is to create a program to calculate the square root of a number provided by the user to an error tolerance 0.005

Looking around i fond the Code: fabs(NG - LG) < epsilon); section that was very similar to what i was using, but if this is better im down for that.

My issue, from what i can see, is the updating of the values of LG. if the test for error tolerance fails then LG needs to take on the value of the results of NG.

Now I am not 100% that is the point of failure due to the fact the script does calculate the root properly, but it never exits the program once it reaches the tolerance level.

Code: imac:ENG-3211 user$ ./hw_4_1

Please enter the number you wish to find the square root: 4

4.00 2.500
4.00 2.050
4.00 2.001
4.00 2.000
4.00 2.000
4.00 2.000
4.00 2.000
4.00 2.000
4.00 2.000

And it continues forever until i manually break the program even though the answer was found, in this example, on the 4th loop.

View 8 Replies View Related

C++ ::  Updating Array In Grading Program

Sep 14, 2014

The program will grade a series of exams and then print a grade report for students in a course.

Input: An instructor has a class of students each of whom takes a multiple-choice exam with 10 questions. For each student in the class, there is one line in the input file. The line contains the answers that student gave for the exam. The input file named "grade_data.txt" will have the following format:

line 1: the key for the exam (e.g.)
bccbbadbca

lines 2-n:
a set of answers. You know you are done when you get to a line with no data.

Note: You will not know in advance how many exams you have to grade and you don't need to store the exam answers in your program.

Processing: The program is to read the input file and grade each exam and print out the score for that exam. You will also keep track of how many students earned each score (0-10) and print a report after the grading.

Output: Here is an example of how the output might appear. You will write the report to an output file named "grade_report.txt"

Student 1 - 8
Student 2 - 10
Student 3 - 1
etc.

Final Report
------------
10 - 4
9 - 2
8 - 3
.
.
1 - 3
0 - 0

high score - 10
low score - 1
mean score - 6.25

What I am having trouble with is the second part of the program. I have already figured out each grade for each student. The part I am having trouble with is updating the array every time that it gives me a student score so that I know how many people made a 10, how many made a 9, etc.

View 1 Replies View Related

C# :: Datagrid Not Updating Styling After Refresh

May 21, 2014

I have a datagrid, which has a column called Status. In the database, the field is a text field that can have the values up, down, or danger.

I needed to display the status as a "light" as per client request, so I have a StatusToImageConverter class that receives the status, and returns the proper image to display in the datagrid column. Works fine.

Now the issue I am having... I have a combo box above the datagrid for the user to filter the results if desired. The filtering works fine, but the newly displayed devices do not have their status light. In the Status column, nothing appears after the user filters. I think it may have to do with the fact that I am not re-initializing the datagrid, but just refreshing it? That's just my educated guess.

XAML:
In the UserControl Resources:

<local:StatusToImageConverter x:Key="ImageConverter" />
In the DataGrid Control:
<DataGridTemplateColumn Header="Status" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>

[Code].....

View 5 Replies View Related

C/C++ :: Updating Window In Game Loop?

May 25, 2014

So I am working on making a game. The first thing I did was make a window class. This correctly makes the window and displays it.

Now, I run my game loop and it just freezes the window and shows the Application has stopped working message box. I believe this is because the Window is not actually being updated.

My game loop however, looks like this.

bool run = true;
while(run) {
Window::Render();
if (Window::IsCloseRequested())

[Code].....

View 4 Replies View Related







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