C :: How To Store Data Structure Into 2D Array

Mar 22, 2013

I have this data store into a data structure.

i j x y w h w*h
0 0 0 0 9 11 99
1 0 0 11 9 10 90
2 0 0 21 9 11 99
0 1 9 0 8 12 96
1 1 9 12 8 7 56
2 1 9 19 8 6 48

[Code]...

Code:

struct data {
//Here
/*! horizontal position */
int x;
/*! vertical position */
int y;
/*! width */
int w;
/

[Code]...

data and then i have an array /*! it contain group_id of each data line*/ int group_id[16]={0,0,0,0,3,3,1,1,1,3,3,2,2,2,2,1}; I never worked with 2D array before. My problem is that i want to create a 2D array of that data for example if i write data[j][i].. It will give me the reference/value of all data lines that belongs to j column, and same with group_id[j][i]. I don't know how i can store these structure vaules in this like 2D array.

View 2 Replies


ADVERTISEMENT

C++ :: Structure To Store Data From Database - Dynamic Initialization Of Variable

Jan 5, 2013

I created a class (let call it X) which contains the structure to store the data from my data base. Them I have a class (call Y) which will contain a list for each row in my data base. Third, I have a class with thousands variables (Z). What I am trying to do is to take the list of objects (Y) that contains the data to initialize Z. What I want to now if I can do something like that.

Imaging that one of my rows contain the following data:
Type Nameofvariable etc...
"static const double; MNFAIL ; 0; 0; 0,25"

In my list I have a node with contain this data

I want to use the field Nameofvariable to initialize the variable called MNFAIL contained in my class Z.

Is it possible in C++

View 3 Replies View Related

C :: How To Store Array Of Structure At Shared Memory

Jan 16, 2014

I have one requirement to store an array of structure at shared memory. Also the shared memory should have one counter to store number of elements in the array.

I tried to look at some placed but didn't find anything relevant.

So my first question, is it possible that we can store two things on same shared memory. And second if not then how to achieve the same?

View 5 Replies View Related

C++ :: How To Store Data Into Array

Apr 18, 2013

How can I store this data into an array?And I only can read the first integer.. 10.... How can I read the whole file...Heres the data:

10 alice 4/23/1972 123-45-6789 support assistant
3 bob 6/7/1980 111-12-1134 logistics manager
1 carol 10/2/1963 987-123-1143 admin ceo
2 dave 10/3/1974 902-22-8914 admin cfo
17 erin 6/13/1991 126-83-1942 technology supervisor
15 frank 2/22/1987 303-12-1122 logistics assistant

Heres what I have so far?

#include <iostream> //Accesses libaries for console input and output
#include <fstream> //Needed to access the fstream object to read files
#include <string> //Needed to access the string class
#include <cstdlib>

[code]....

View 1 Replies View Related

C/C++ :: Store Data From A File Into Array Of Structs

Mar 10, 2015

That;s what i have so far: problem: the output data is not correct.

input file
1301 105515018 "Boatswain" "Michael R." CSE 230 ="R01"
1301 103993269 "Castille" "Michael Jr" CSE 230 ="R03"
1301 103993267 "Castille" "Janice" CSE 230 ="R03"

[Code]....

View 1 Replies View Related

C :: Implementing Trie Data Structure With Dynamic Array

Jun 23, 2013

i can't implement trie with dynamic array .the problem is in this line i think :

Code:

childs_size = (node_p -> childs_value_p)[0] + 1; here is my code : Code: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct trie_node {
unsigned char *childs_value_p; // pointer to an array of child nodes value
struct trie_node **childs_ptp; // pointer to an array of child nodes pointer
struct trie_node *failure_node_p; // pointer to failure node

[code]...

i could write this code with binary tree instead of dynamic array but need a large amount of memory for about 13000000 strings of length 16 . is there any better solution with lower memory usage to implement trie ?

View 8 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++ :: Capture Incoming Serial Data And Store It Into Array For Controlling Functions

Mar 22, 2014

How to capture incoming serial data and store it into an array for controlling functions. But I am now working with a radio module that receives incoming data and stores it into a uint_8t.

From there in the basic sketch that the radio library came with it is printed in the serial terminal like this:

uint8_t buf[RF22_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf22.waitAvailableTimeout(500)) {
// Should be a message for us now
if (rf22.recv(buf, &len)) {
Serial.print("got reply: ");
Serial.println((char*)buf);

I have read a lot of tutorials on pointers, and I am just having a very hard time grasping how to extract data out of one. I realize this is char and not integers. The goal is to transmit five integers in a digital state of either 1 or 0, and then store them in the receiving side and control 5 outputs based on the status of those 5 bits. This is proving to be quite confusing for me though as I cannot seem to grasp how to control the pointer logic.

View 1 Replies View Related

C :: Is NodePtr Store Address Of Structure

Feb 1, 2015

I'm reading through a data structure textbook. I'm doing the part of Linked list. here's the code from the textbook:I'm not clear with pointer.what I'm confused is that the code created a pointer to the structure (*NodePtr)

Q1. Is NodePtr store the address of the structure??
Q2. Are top, np, last address of the structure??
Q3. here.....NodePtr makeNode(int);... does it returns an address of the structure which is np?? but following part np is used as a pointer??

Code:

#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int num;
struct node* next;
}Node, *NodePtr;
}

[code]....

View 4 Replies View Related

C++ :: Structure To Store Information About Movie

Oct 14, 2013

Directions: Write a program that uses the structure named MovieData to store the following information about a movie:

Title
Director
Year Released
Running Time

Include a constructor that allows all four of these member data values to be specified at the time MovieData variable is created. The program should create. The MovieData variable and pass each one in turn to a function that displays the information about the movie in a clearly formatted manner. Pass the MovieData Variables to the display by value.

Code:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct MovieData {

[Code] ....

I sort of hit a wall did it do something wrong because the whole create two MovieData variables is confusing me.

View 1 Replies View Related

C :: Create A Structure To Store Information About Products For Sale

Apr 29, 2013

I am using Dev C++ compiler on Windows 7 and was programming a piece of code that is supposed to do the following -

Create a structure to store information about products for sale in a store. It should store information about the product name, the price, and the product number and then create an array of products called Inventory. Add five products to your inventory.

But for some reason, which is unknown to me, I always seem to get a compiler error. And this is what i have so far -

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct product{
char name[30];
int product_number;
double price;

[Code] ....

View 4 Replies View Related

C++ :: Read Input From User And Then Store In Structure Variable

Apr 6, 2014

My program is designed to read input from the user and then store that input in a structure variable. Whenever i use the cin.getline() function, it comes up with a semantic issue. Here is the code:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int DESCRIPTION_SIZE = 100, DATE_SIZE = 20;
struct inventory {
string description[DESCRIPTION_SIZE];

[Code] .....

I left out the other functions. The error reads "no matching member function for call to 'getline'.

View 6 Replies View Related

C :: Store Data In Binary File Then Use It To Find Inverse Of Matrix Form Of Data

Dec 6, 2013

I need to find inverse of a matrix data in binary file should be used to form matrix.its not finding inverse correctly rest is working good.

Code:
#include <stdio.h>
void createbin();
void display();
void inverse();
int main()
{
createbin();
display();
inverse();

[Code] ....

View 4 Replies View Related

C++ :: Add Data To Text Files Which Are Required To Store 3D Scan Data

Jul 10, 2013

I have written the following code to add data to text files which are required to store 3D scan data (I have to calculate the y-coordinate). My code seems to work except that it stops working when I want to create more than ten text files i.e. the directory I am trying to store them in will not hold any more than ten text files. Code is shown below.

#include <string>
#include <locale>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;

[Code] ....

View 1 Replies View Related

C++ :: Best Way To Store Data?

Jul 8, 2013

struct Book{
string bookTitle;
string ISBN;
string author;
string publisher;
string dateAdded;
int qty;
double wholesale;
double retail;
};

What's the best way to store multiple of the above structure?Ideally, it would be with a binary output, but that isn't possible with the strings, unless I'm missing something. So that leaves me with two options.

-Create a second structure that has an outrageous char[] length, and then copy the data from the original structure to write/read to/from the file. The flaws I see in this is excess runtime with copying, and a larger amount of memory is temporarily needed. The positive I see is I can use binary output, which is easier.

-The second option is to just use an ASCII file, and put each element on it's own line, and then just use getline to read each line. The flaw I see in this is that I have to read the file into the structure, instead of just reading the structure and the file can be tampered with (Not a huge concern). The positive is the lack of negative from the above.

View 4 Replies View Related

C :: How Data Actually Store In File

May 19, 2014

How data actually store in the File. Like do data store just in one line or at different places for example in array data store in adjacent memory block while in struct data store at different memory block.?

View 2 Replies View Related

C++ :: Using Arrays To Store Data?

Mar 25, 2013

start writing a program to store some information and then have it recalled. I would like to be able to store a list of the video games I own because i thought it would be fun :)

View 1 Replies View Related

C :: Scope Of A Data Structure

Oct 9, 2013

how to solve this undeclared error when compiling this code. I assume it has something to do with scope.

C code - 47 lines - codepad

Code:

#include <stdio.h>
int main(void) {
struct bank_account {

[Code].....

View 3 Replies View Related

C++ :: Asymmetric Data Structure

Mar 18, 2013

I am trying to create an structure of data with following elements:

struct stest {
std::vector<int> na;
std::vector<double> nb;
std::vector<double> va;
std::vector<double> vb;
std::vector<double> vc;
std::vector<double> vd;
}

I would like to modify the composition of this struct, so that I can create a special data structure by

vector<stest*> data_test;
for(int i = 0; i < 10; i++)
data_test.push_Back(new stest);

within this structure, I have: only one na and one nb, but ten groups of combination of va, vb, vc, vd that I can access by pointer, which means na, nb are independent but still inside of the structure.

View 2 Replies View Related

C++ :: Two Dimensional Map - Data Structure

Apr 4, 2013

I'm currently having the following data structure:

typedef struct {
int a;
int b;
} S;
<vector <vector<S> > v;

Now I also have different pointers that can be set in connection with one instance of the above shown vector. Therefore I was attempting to work with a map:

map<p*, <vector<vector <S> >, vector<sI> > m;

However, it seems like it doesn't work that way. Therefore I tried the following:

map<p*, map<<vector<vector <S> >, vector<S> > > m2;

With this attempt I do now, however, get another mistake here, that [] cannot be used here:

S s;
m2[p][0].push_back(s);

View 13 Replies View Related

C++ :: What Data Structure Does A Vector Use

Dec 14, 2013

Does it use Linked List or Dynamic Array?

I want to know this because if I happen to want to use a lot of insertions and deletions then it is more efficient to make use of Linked List instead of Dynamic Array.

While, if I happen to want to just access random parts of the Array, then Dynamic would be more efficient.

I want to make a 2D game using SDL engine and I need to check whether or not an object is colliding with a list of other objects. (because there would be more then one objects on the map.)

Since I would simply be accessing each object sequentially to check whether or not the object is colliding with another the object in question, and since any of those objects could "die" and be deleted at any time, it makes more sense to use Linked List then a Dynamic Array.

View 8 Replies View Related

C/C++ :: How To Use One Structure Data In Other Structures

Jul 2, 2014

I created one structure and the created structure is using in few more structures, but i did not get the proper data.

typedef struct _MSG_HEADER{
//MESSAGE_HEADER 40 bytes
short iApiTcode;
short iApiFuncId;
int LogTime;
char AlphaChar[2];

[Code]...

My requirement is have to fill the MessageHeader structure & we can use that header in all the structures entire program.

View 3 Replies View Related

C++ :: Vectors With Structure - How To Add Data

Nov 26, 2014

I have two structs like below,

struct SP {
string sp1;
string sp2;
};
struct SL {

[Code] ....

How to add data to slVect ?

View 6 Replies View Related

C++ :: How To Store Data From A Class Into A Container

Feb 10, 2013

I'm having trouble understanding on how to actually store into a container from another class. Any simple example.

View 9 Replies View Related

C++ :: How To Store And Retrieve Data In Class

Aug 20, 2014

I have a class I use to store column data read from delimited text files.

Code:
class column_data {
// class functions here
public:
// initialize class members
column_data()
: header(""),

[Code] ....

Each column is read into the vector of string. Next the string data is copy converted to the vector of double or the vector of int depending on the data type. There can also be additional transformations of the data (normalization, scaling, etc) and the transformed data is copied to the transformed_double_data vector. I do end up with multiple copies of the data, but I can clear some of the vectors if I don't need all the versions of the data anymore. Each column object goes into a container like a vector of objects or map of objects depending on how I need to access the column data.

There are functions that calculate statistics on the data in the columns and the results are assigned to the object variables like validate_r2. There are separate statistics for each column, so it seems logical to store the results in the column object. This works well for statistics like validate_r2 (pearson's correlation coefficient).

The current issue is that I have other statistics like "pw50" that I need to calculate and store. The statistic is the percent within +/- 50 units and the request for pw50 is passed in from the command line. The issue is that there could be several of these and they can have more or less any value like, pw50, pw75, pw100, etc. Storing data like this doesn't fit into my scheme very well because I can't pre-declare a variable to hold the result for every possible option. I don't know in advance how many, if any, of these there will be. I was thinking of adding two vectors, one of string and one of double,

Code:
class column_data {
public:
// initialize class members
column_data()
: header(""),
type(""),
use(""),
validate_r2(0.0),

[Code] ....

For each of this type of statistic requested, I would push_back a label into the string vector and then put the result into the parallel position in the double vector. This seems like I would work, but there are probably some things that could be done with pointers that might be better. Another option would be a vector of objects where each object had a string value for the label and a double for the result. That would be more bullet proof as far as keeping the label and value together, but I have not ever nested objects in a class like that so I thought I would post. I don't know the syntax for declaring an object of class_b inside the definition of class_a. The need is to provide dynamic storage for an unspecified number of these statistics and a reliable way to retrieve the values using the label.

View 1 Replies View Related

C++ :: Using Custom Class For STL Set Data Structure

Oct 27, 2014

When we want to use custom classes for the STL set data structure, how to do it?

I look around and see people passing comparators, overloading operator(), and also overloading operator< in the class itself.

Which one's the idiomatic c++ way?

View 1 Replies View Related







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