C++ :: Storing Data To CPU Memory?

Mar 27, 2013

Is it possible to store data to CPU memory, if so how much memory can I store and how? Say I wanted to store an array, about 6MB in size?

View 1 Replies


ADVERTISEMENT

C :: Is Extra Memory Allocated For Storing Address Of Array

Jul 8, 2014

When declaring char array[10], memory is allocated for 10 1-bit memory locations. Is extra memory allocated for storing the address of array[0]? In expressions, is array equivalent to a pointer constant or is it an identifier for a memory cell containing the address of array[0]? In other words, is array a variable or an alias for &array[0]?

View 6 Replies View Related

C :: Storing PPM Data Into Arrays

Mar 29, 2014

I am doing this program where I analyze colors in a ppm file. Now I am having a hard time storing the data into arrays in this order...

P3
600 339
255
44 5 8
44 5 8
43 4 7
42 3 6
42 3 4
44 5 6
...

So far i tried using fscanf()

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

#define DEBUG true
#define CHECK true

[Code] ....

I then realized that the order that the second method gave me will make it very hard for me to calculate the RGBs. Because they will be calculated like wise..

P3
600 339
255
44 5 8 = sum
44 5 8 = sum
43 4 7 = sum
42 3 6 = sum

42 3 4 = sum
44 5 6 = sum
...

but that isn't the issue right now..

View 10 Replies View Related

C++ :: Storing Data From 2 Columns In CSV

Oct 17, 2013

I have a file that can range from 100 rows to 10000+ that is comma delimited with 8 columns. The first 32 rows (also comma delimited) will always be ignored (geographical header information). I will be wanting the data from column2 and column3.

For this I believe I would need (2) For Loops as such:

for(i=0;i<2;++i) {
getline("do something here");
}

and

for (i=0;i<3;++i) {
getline("do something here")
}

Also would using a vector or array with dynamic storage be the better way to tackle this problem? Where to start from after accessing the file.

View 19 Replies View Related

C++ :: Storing Data In A File?

Apr 12, 2013

I am trying to store the Title, Artist, and date published of a list of CD's. I can't seem to be able to get it to print the list or not sure if it is actually storing it. This is what i have so far.

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main() {
char names[5][100];

[code]....

View 2 Replies View Related

C++ :: Map Storing Multiple Data Types

Jul 11, 2014

I am trying to create a generic map container which shell contain data of different datatypes. I already found a solution in this forum here:

[URL]...

Introducing a container with a Base Class as content type and inserting objectes of Derived Class types from that Base Class suites my implementation very well. But it is not really working. I implemented it this way:

class MyType {
public:
MyType() {}
virtual ~MyType() {}
}; template <class PT> class ParseType : public MyType

[Code]...

Then I insert one element.

// index being an object of type Parser<string>
ParseType<string>* test = new ParseType<string>( index );
// and index.val(0) = "-n"
iMap.insert( pair< string, MyType* >( index.id(0), test ) );

Now I think I should be able to call

const string key("-n");
iMap.at(key)->content->val(n);
Or
iMap.at(key)->get_val(n);

But neither one compiles with the error that "class MyType" (as the map container is pointing to a MyClass object) has no member/member function "content"/"get_val".

I also tried introducing member and member function "content" and "get_val" in "class MyType", which I thought should be hidden while constructing ParseType<string>. This would compile but it does not call the member "content or member function "get_val" from class ParseType.

A second try was to remove templatization of "class ParseType" and introduce a specific, let's say, "class ParseString" for objects of type Parser<string>. But the problems remain the same either the compiler complains due to missing member/member function or retreiving the map content will not call the derived class member/member function.

View 4 Replies View Related

C++ :: Reading And Storing CSV File Data

Feb 21, 2013

I am working on a small c++ project where i read from a csv file with information in this format:

string,string,int
string,string,int
string,string,int

And all of the above information is one person. As is "John,Peter,23" is first name, last name, age. When there are multiple people in a csv file how can i parse through and separate the information in a string and int for later use?

View 4 Replies View Related

C++ :: Storing Data As Void And Dereferencing Them Later?

Jan 15, 2013

I have a set of functions at work which are incredibly useful, however it only supports labels that come from a specific database because that database contains information on the type. I'd like to re-create it to make it more applicable to any member/static/global variables but don't know how to store the type.

I've already re-written it to an extent, but it only accepts int types. I'd like to template it to accept any type. The trick is storing that type so that the pointer can be dereferenced at a later time which I don't know how to do.

Interface:

typedef int T; // The goal is to remove this line!
namespace TimerDelay {
void SetAfterDelay ( T* lpLabelAddress, float delay, T target = T(1)); // Queues the set
void ManageDelays ( float dt ); // sets the labels when appropriate
}

Source:

#include <vector>
namespace TimerDelay{
struct DelayObject {
void* address; // I will probably need to add a container
void* target; // to hold the type, but how can this be done?

[code]....

Edit:Is it possible to store a std::iterator_traits<> struct as a member of my structure? The g_list isn't templated as it needs to accept all types at the same time. That means that DelayObject cannot be templated. I think that means that I cannot use a templated member class as the size may be inconsistant.

View 2 Replies View Related

C++ :: Reading Data From File Then Storing It To Reuse?

Mar 27, 2013

Im tasked with reading a data file, this is an example snippet

list of trophy winners
year facup leaguecup 1stdiv 2ndiv
1960/61 Tottenham Hotspur Aston Villa Tottenham Hotspur Ipswich Town
1961/62 Tottenham Hotspur Norwich City Ipswich Town Liverpool
1962/63 Manchester Utd Birmingham City Everton Stoke City

The file starts in 1892 and is up to 2011/12, there is data missing for some years due to the wars etc,

once ive read the file, i need to store the data, for me to re-use.

There are a lot of useful link regarding reading data in, but they tend to be with very small files with say 10 lines of numbers.

View 1 Replies View Related

C++ :: Storing Constant - Frequently Accessed Data

Sep 9, 2013

I'm redesigning some code and I'm wondering what the best ways to store and access certain data is. The characteristics are as followed:

1) Based on data from a file, a distance matrix (N x N) is calculated.
2) Once the matrix is complete, the data will never change (unless a new file is read, but I can work around that by iteratively calling the problem with a new datafile on as command line parameter).
3) The data from the matrix is accessed billions of times from pretty much every other line of code.

In my old version, I had a class "Data" which a sub-class "Data::Distance" and I would put a reference in every other class that needed it. Now, my class hierarchy will be much flatter (basically all logic will be in one class; other classes will be POD structs).

Given the characteristics of the Distance table, is there a way to store them in a very efficiently-accessible way? Does it matter if it's stored in the main class where all the action happens in contrast to being a different class? Does making it static improve the performance? Casting it to const? Anything?

Again, the data is accessed billions of times so even minor differences can save a lot of time.

View 10 Replies View Related

C/C++ :: Storing And Retrieving Large Amount Of Data

Nov 28, 2012

I have to store large amount of data and retrieve the same data then write into file in C++. Currently I am using vector to store and retrieve. But vector is taking more time to store and retrieve the element. Is any other best data structure to store and retrieve large amount of data in unordered way?

Example code:

int I1 = 700,I2 = 32, I3 = 16;
//declare and resize the vector size
vector< vector < vector < vector<DOUBLE> > > > vPARAM; 
vPARAM.resize(I1, vector< vector < vector<DOUBLE> > >

[Code] ....

View 3 Replies View Related

C :: Storing File Data In A Structure Of Format Shown

Aug 5, 2014

I'm having trouble reading my data from a .txt file into a structure of the format shown in my code. I've made my student database in the program below based on user input and I didn't have a problem with that, but now it's come to input from a file it's making it difficult.

My three tasks are:

(1) A table containing 1 row per student, containing the student ID number and all of the student's marks.

(2) Another table, containing 1 row per student, containing the student ID number and the average mark obtained by that student.

(3) The average mark for each subject.

The assumptions to be made are: The student ID can begin with a zero, and should therefore be read in as a string.The test data will contain 20 students but the program should be able to deal with up to 100 students.Assume there are no more than 4 different subjects.

So based on the first assumption I've arranged the data in the file in an order in which the student ID begins with a zero:

003953 Computing 38
003953 English 88
003953 Mathematics 29
003953 Physics 83
073241 Computing 63
073241 English 99
073241 Mathematics 32
073241 Physics 73

...for twenty students, 80 lines of data. Now, on the assumption they must be read in as strings, this is what's making it tricky to store in the structure because, I've got 80 ID numbers but 20 repeat themselves 4 times. Once I've got this data in the structure below the tasks I won't have a problem with because I can just base it on a user input program but the data's already stored instead.

Below is my code for user input associated with task (1). In this example the IDs are stored as ints but for the file they will be strings. It compiles fine, displays the data as shown in the assignment sheet, but I don't know how to get the data into my structure. I can store the data in a structure of three arrays using fscanf() no problem, but it's not very "workable" for what I need to do with it.

Code:

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

[Code].....

View 11 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++ :: Bank Account - Function Not Storing Data In Array

Mar 5, 2014

Following function is from a bank account, when new account is created it won't store it in the array or i guess it does but find_acct function wont be able to find it.

find_acct Function:

int findacct(int acctnum_array[], int num_accts, int requested_account) {
for (int index = 0; index < num_accts; index++)
if (acctnum_array[index] == requested_account)
return index;
return -1;

[Code] ....

View 2 Replies View Related

C++ :: Reading And Storing Newline Character Alongside Data

Jan 6, 2014

I am reading data from a text file into a program. I am well aware of the subtle distinctions in the mode of data input/entry when using the stream extraction operator, the get() function, and the getline() function.

My problem is that all of them do not read and/or store the newline character alongside the data read!

Any function that reads and stores data and the terminating newline character together??

View 1 Replies View Related

C++ :: Storing File Data In Array With Structure Type?

Feb 20, 2015

I have a structure

struct Wine
{
string wineName;
int vintage;
int rating;
double price;
};

how can i store the file data below in an array with the structure type???

Dow Vintage Port ;2011;99;82
Mollydooker Shiraz Carnival of Love ;2012;95;75
Prats & Symington Douro Chryseia ;2011;97;55
Quinta do Vale Meão Douro ;2011;97;76
Leeuwin Chardonnay River Art Series ;2011;96;89

View 1 Replies View Related

C++ :: SerialPort Communication - Reading Data From Port And Storing In One Document

Jun 27, 2014

I am doing SerialPort communication program where i am opening the port and reading data from port and storing in one document.

I debug my program and check that my read function is reading the data properly but when checking the document i find only unicode.

Suppose I am sending 1,2,3,4 to port i able to read same but my document showes þÿÿ þÿÿ þÿÿ þÿÿ

//My Read Function which read data from serial port
tInt serialport::Read(tVoid* pvBuffer, tInt nBufferSize) {
tInt nBytesRead = 0;

[Code] ....

Why I am getting unicode instead of 1,2,3,4 in my document ....

View 3 Replies View Related

C :: Manipulating Data In Memory

Jan 31, 2015

So, it seems I have a bug in my code:

Code:

char *mem = malloc(9), *bottom = malloc(3), *in = "abc";
int position = 2, i;
mem = "onetwo";
printf("OLD mem = %s
", mem);

[Code]....

What I'm trying to do is insert "abc" in the 3rd position of "onetwo". Results would be "oneabctwo", but all I get is crashing.

View 9 Replies View Related

C/C++ :: BST - Cannot Access Memory Data

Nov 11, 2014

When I return mem add I cannot access the data in that add: in bin search tree

Curr=findMin(root);
cout<<"val: "<<Curr->barcode<<endl;
bst::hwareItem* bst:: findMin(hwareItem*& root){

while(root!=NULL){
root=root->left;
}
return root;
}

View 1 Replies View Related

C# :: Download Data From Memory Controller

Jul 11, 2014

Using the C # programming language LED controller through which controls the array is connected to the controller via the RJ45 port. I already know the basics, I mean specifics, ie

Using the instructions and DLL included with the hardware, I want to read data from it, but I can not deal with it.

Model controller is "C-Power5200" and dll is "CP5200.dll".

I would like to:-pick the data-display-edit and - save in the controller.

To read the data I am using the function

CP5200_Net_Read (BYTE * pBuf, int nSize);

and to save

CP5200_Net_Write (const BYTE * pBuf, int nLength);

View 2 Replies View Related

C :: Reading Data From CSV File Or Memory Onto Screen?

Jul 26, 2014

I have a csv file (comma delimited text file really) and I have data ,about 6400 lines, and I need to read and display data from 1 line. At the bottom is sample data from my csv file.

I want to read onto the screen the 3rd item .. ie Test User 1 and the date and time at the end (the last 2 items).

I will enter in a number .. from which I will want to retrieve the appropriate record .. in this case I would enter in 514, 563 or 874 and get back the info for that record.

This is a DOS 16 bit application .. and I know that some of the data is in memory already but I am not sure how to tell .. or how to retrieve it.

I do have the ability to save the data to the file at any time .. so I can use that to ensure that the data is current in the text file before I retrieve the data from this 1 row.

I think that it may just be easier to get from the text file ? but I am not sure.

0000,7,0,"Test User 1",53c145cb,db,5,514,514,2014/07/12,10:27:23
0001,7,0,"Test User 2",53d7f,1903,10,563,563,2014/07/24,11:04:31
0002,7,0,"Test User 3",529c,5ffb03,0,874,874,2013/12/02,09:07:58

I am a database guy .. and I am just a bit lost when it comes to C programming as such.

View 9 Replies View Related

C++ :: Printing Data As It Is Stored In Memory (binary)?

Mar 21, 2013

So, if I'm right, computer store their data as binary values. So if I write int x = 5; , my computer converts the value of x from decimal (5) into binary (101) and stores it in memory as a a binary number. If I print that value on the screen that value is converted(by default) back into a decimal number before being printed on the screen.

Now, my question is if there is any way to print the value of x directly into binary(as it's stored in memory) without it being converted back into a decimal value?

View 10 Replies View Related

C++ :: Data Buffer With Memory Mapped Files?

Jan 27, 2014

I have a data buffer project in Windows 7 x64 embedded OS (using Visual Studio 2008), that would work simply like that:

One writer application will send data (no network protocols, just procedure call on the same machine) to my app like 20 packages per second, each data packages will be approximately 3 MB size and comes with a timestamp tag.

My application will store each data item for 100 minutes and then remove. (So I can calculate the total size from beginnig no need for dynamic allocation etc...)

Meanwhile there will be up to 5 reader applications which will query data from my app via Timestamp tag and retreive data (no updates or deletitions on data by reader apps).

So since the data in my buffer app can grow over 50GB I don't think that shared memory is going to work for my case.

I'm thinking about using Boost Memory Mapped Files or Windows API Memory Mapped Files.

So theoratically I will crate a fixed size File on harddisk (lets say 50GB) and then map some portion to RAM write the data to this portion, if the reader applications wants to use the data which is mapped currently on memory, then they will use directly, otherwise they will map some other potion of the file to their address spaces and use from there...

My problem is I haven't use Map File concept at all and I'm not a C++ developer so I'm not very familiar with the language fundementals. I've searched tutorials of boost and msdn for windows as well but there is not too much code example.

So I don't know how to map some portion of the data to memory and manage it, also how to search data in file or memory according to the timestamp tag. Yes there are codes for creating files and mapping the whole file to memory but none for dividing it into regions, aligning or padding the data which I need for my case.

View 2 Replies View Related

C# :: Store Data In Memory After Adding Values

Oct 23, 2014

I serialize a XML file, and i have this values here:

public class ServiceConfig {
public List<DatabaseDescriptor> Databases { get; set; }
} public class DatabaseDescriptor {
[XmlElement("Name")]

[Code] ....

I have a form1 which is a datagrid view and get's updated like this:

dataGridView1.DataSource = xmlData.Databases;

Now i have a button: get tables, and it opens up form 2, there it's supposed to appear all the tables of the selected Database, when i click on the row i get the database name so i get all the list of Tables from

DatabaseDescriptor
where
DatabaseDescriptor.Name == name
(I get this when i select the row)

But then on the 2nd form, i also have 2 textbox so i add a new table, i add the tablename and id. the new value should appear in the datagridview of the tables, and when i close it and reopen it, it should be there. Maybe i should concatenate first the values or something, how do i do?

View 3 Replies View Related

C/C++ :: Intuitive Data Structure To Use For Memory Management Program

Mar 21, 2014

I have an assignment that wants me to better understand how certain calls like malloc() and free() work. I'm supposed to have one function that allocates a pool of memory for the program to use (this is the only place where I'm allowed to use the malloc function. Anyplace else is off limits, except when allocating space for data structures.) Another function needs to be defined that allocates memory from this large pool of memory that we have already allocated. A third function needs to free a block of memory when a call from function main is made and a fourth does something else (haven't gotten that far yet.) I'm not sure if it's ok or not, but I'll attach the pdf form that describes all the requirements. If that's not ok, I'll delete it.)

Anyways, when thinking of data structures to use for this particular problem, one doesn't jump out at me as being THE data structure that would be most useful. How I would imagine using it is to store the addresses currently being used as well as the block length of those addresses (so basically, each node of the linkedlist would have a pointer that points to an allocated address and another field that told the size of the allocated block of memory.) How to communicate to the large pool of memory that a certain block of memory has been allocated and shouldn't be used until a free is made on that specific block of memory.

Attached File(s)
pa3.pdf (61.07K)

View 2 Replies View Related

C++ :: Generate Array Of Data Using Templates Into Programme Memory?

Apr 24, 2013

When you have constant arrays, they are stored in the programme memory space. Upon execution, they are copied into the data space for easy access. To save space in the data space, it is possible to stop it from being copied. Some compilers will deal with this by just specifying the array as const, g++ has a type modifier called PROGMEM.

In any case, the problem is that I'd like to generate some data, preferably without using an external programme to do it. Hence, my question using the template system. Now I could possibly use macro metaprogramming via boost instead of template metaprogramming, and I may have to go that route. However there are limitations, especially since its numbering system is only equivalent to an unsigned byte, which I possibly could use, but could become more messy than if I use the template system that has long long types as well as a whole slue of type safety mechanisms.

View 14 Replies View Related







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