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


ADVERTISEMENT

C++ :: Structure Record Type In Array - Unresolved Structures

Feb 25, 2015

Why I do have this error message?

1>------ Build started: Project: TMA04, Configuration: Debug Win32 ------
1>TMA04.obj : error LNK2019: unresolved external symbol "double __cdecl getFees(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getFees@@YANV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>C:UsersEvgericDocumentsVisual Studio 2010ProjectsTMA04DebugTMA04.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

View 1 Replies View Related

C :: Saving Matrices With Data Structures?

Dec 4, 2014

I'm taking a programming class and currently we're doing data structures. Today, we discussed how to save square matrices column-wise with data structures. The teacher said that after the first few steps where you declare the structure, allocate the matrix, free it and get the dimension (which mostly make sense to me I think), you have to "get" and "set" the matrix by putting in something like

Code:
void setMatrixEntry(Matrix* A, int i, int j, double Aij) {
A->entries[i+j*A->m] = Aij;
}

[Code]....

View 7 Replies View Related

C :: Reading Data File Into Array Of Structures?

Nov 2, 2014

I'm reading the following file:

Osgood,Marcus 298542123 CHM FR mosgood@whatever.edu
Cronk,Melissa 873489021 BIO SR mcronk@whatever.edu
Pry,Seth 349908431 MTH SO spry@whatever.edu
Langlais,Susan 783323545 ME SR slanglais@whatever.edu
Davis,Nicole 987543345 PHY FR ndavis@whatever.edu

It's supposed to split it up into name, ID number, major, year, and email. The file reads it without any errors, and assigns name to the first part of the structure. However, ID gets assigned the ID, major, year, and email. Then Major gets assigned major, year, and email. Year gets assigned year and email, while email just gets assigned email. I don't know if it has something to do with the loop. For example, this is what I get what I print just the name and the ID.

Cronk,Melissa 873489021BIOSRmcronk@whatever.edu

Pry,Seth 349908431MTHSOspry@whatever.edu

Langlais,Susan 783323545ME

Davis,Nicole 987543345 PHYFRndavis@whatever.edu

Anyway. This is my function code for reading the array. I have it printing the ID number just to see if I can catch the errors earlier:

Code:
#include <stdio.h>
#include <string.h>
#include "functions.h"
void read_data(char filename[], studentinfo_t s[], int *size) {
FILE *infilep;
int countstudents = 0;
infilep = fopen("student_data", "r");

[Code].....

the name is reading correctly, but not anything else!

View 1 Replies View Related

C++ :: Dynamic Data Structures (Linked List)

Oct 26, 2013

I need an explanation of what linked lists are. How the nodes are been defined and used, especially in an object oriented programming. With a code example.

View 1 Replies View Related

C++ :: Dynamic Data Structures And Information Input

Feb 17, 2013

I want to have input data stored in a database. All information entered is to be stored under a single block. That way whenever I want to recover that information all I have to do is point to that block. Think of it like this. I want a large square block that can hold certain information. Inside of that large block are a finite amount of smaller blocks in which the user entered information about a single subject. Lets say block 1 has a name, address, and phone number. The second block will have the same TYPE of information, but different values as entered by the user. I.E:

BLOCK 1: Name 1, Address 1, Phone 1
BLOCK 2: Name 2, Address 2, Phone 2
etc.

The large block contains all of the smaller blocks, we will name the large block "Address Book" ... How would I implement that? Of course it would be just a simple console program that would erase all information when the program shut down, but I've been trying to figure out how to do it, but just can't seem to grasp a good notion of how to do it. What would be the best way to do that? Structures? How would I make it dynamic so that I wouldn't have to define every block, so that it would be added on the fly when someone inputs new information.

View 2 Replies View Related

C :: Reinforce Use Of Data Structures / Finding Highest Score

Apr 16, 2014

We're writing a program in class using data structures and arrays and I'm stuck on writing a loop to find the students' highest test score. I only return the first student's ID, test score, and grade. For some reason unknown to me I'm not actually looping through all 12 or so records.

Code:

#include <stdio.h>
#define MAX_ENTRIES 50
struct records
{ //declare my student records structure
int ID; //the student's ID number
int test_score; //the student's test score
char grade; //the student's letter grade of aforementioned test score
};

[code]....

View 5 Replies View Related

C++ :: Passing Data Structures To Function Pointers And Get Values

Sep 26, 2014

typedef struct example_dt_struct {
int a;
float b;
char* c;
};
typedef void(*func)(example_dt_struct *s, int e, int f);
void f(func *n){}

how can i use example_dt_structure with my function pointer into f()

View 5 Replies View Related

C++ :: Making Data Structures For A Rectangle And Square In OpenGL

Feb 3, 2014

So this makes an output of the head (a square), and the leg (rectangle. How do I make my points into a data structure in the shortest yet simplest way possible?

#include <vector>
#include <time.h>
using namespace std;
#include "Glut_Setup.h"
float
head1x= -0.5, head1y=3, head1z=0,
head2x= 0.5, head2y=3, head2z=0,
head3x= 0.5, head3y=2, head3z=0,
head4x= -0.5, head4y=2, head4z=0;

[Code] .....

View 10 Replies View Related

C++ :: Simple Rectangle - How To Make It Move Using Data Structures

Feb 27, 2014

So I made a code that shows a simple rectangle. How do I make it move using data structures? :)

Code:
#include "Glut_Setup.h"
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <time.h>
using namespace std;

float P1= -5;
float P2= 2;

[Code] .....

View 2 Replies View Related

C/C++ :: Read BMP Image Data Into Multidimensional Array Of Structures

Apr 8, 2014

I am trying to read the information from a .bmp file into my program while dynamically allocating memory for all of it. So I defined the structures for the headers and for a pixel, and then I have to read each pixel into a multi-dimensional array of pixels. I am completely new to structures, and definitely new to pointers combined with structures. I will have to use a filter with the information later, but right now I just want to read everything in correctly. The array of pixels will be two-dimensional -- the width by the height of the image, I guess.

Here's my code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *inFile, *outFile;
typedef struct

[Code] ....

View 4 Replies View Related

C++ :: Why Projects Always Roll Their Own Data Structures / Utility Classes

Jun 9, 2014

Why certain projects always roll their own data structures/utililiy classes rather than using the C++ standard libraries? such as linked lists and queues? Is there a particular reason for this?

View 11 Replies View Related

C++ :: Use Circular Linked List And Data Structures To Store Tasks

Mar 30, 2014

The program use a circular linked list and data structures to store the tasks.

- Every task should include a task name, a name for the person assigned to it, and the deadline for the task.
- Variables should be dynamic and their sizes should be determined at runtime based on the length of user input.
- You should implement the following functions (with appropriate arguments and return types) for your structure: add(), remove(), search(), and list().
- The add()function should add tasks alphabetically by task name. You do not need to implement any file operations.
- The search() function should be able search for a task by the task assignee name or the task name.
- The list() function should print records to the screen in the order they appear in the circular linked list.
- You should successfully deallocate all of the allocated memory before termination of your program.

View 4 Replies View Related

C++ :: Data Structures - File Size Not Decreasing When Erase A Record

Nov 26, 2014

// my size is not decreasing when I erase a record.
//dvr_hwch.cpp

#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;
#include "hash_chn.h"
void print_menu( );

[Code] .....

View 1 Replies View Related

C++ :: Read Data From File Then Make It Into Array Of Structures And Print Afterwards

May 13, 2012

I am trying to read from a data file that has input as :

12.0, 11, 123
14.0, 12.1, 3

And I want the program to read the data from the file and then make it into an array of structures and then print that array afterwards.

Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_INPUT 1000
int n =0;
int i = 0;
typedef struct {
double x[MAX_INPUT];

[Code] .....

The program when run gives the following output:

Ishtiaque-Mohammed-Khans-MacBook-Pro:Comp20005 IshtiaqueMKhan$ gcc -Wall -ansi -o ProjectB ProjectB.c
ProjectB.c: In function "main":
ProjectB.c:59: error: incompatible type for argument 1 of "print_array"

View 1 Replies View Related

Visual C++ :: Employee Payroll Program Using Structures Does Not Show All Data

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

C :: Append Data To Array Of Structures In Memory Then Put In File When Program Ends

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

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++ :: 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++ :: 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

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 View Related

C++ :: Corporate Data Sales Structure

Nov 20, 2013

Corporate Data Sales

Write a program that uses a structure named CorpData to store the following information on a company division.

Division Name(North, South, East, Or West)
First quarter sales
Second quarter sales
Third quarter sales
Fourth quarter sales
Total annual sales
Average quarter sales

Include a constructor that allows the division name and four quarterly sales amounts to be specified at the time a CorpData variable is created.

The program should create four variables of this structure, each representing one of the following corporate divisions: North, South, East and West. Each variable should be passed in turn to a function that calculates and stores the total annual sales and average sales for that division.

Once this has been done for each division, each variable should be passed in turn to a function that displays the division name, total sales, and average sales.

Here is my code:

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
struct CorpData {

[Code] ....

View 1 Replies View Related

C++ :: Data Structure - To Check If A Set B Is A Subset Of A Or Not

Feb 9, 2013

To check if a set B is a subset of A or not. Which data structure to be used to store set A for quicker response(linked list/hash map)? What if I want to check intersection also?

View 1 Replies View Related







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