C++ :: System That Communicates With Other Systems Via Messages - Struct Member Manipulation

Dec 5, 2012

I work on a system that communicates with other systems via messages. Those messages are defined in a spec and every word must be exactly as defined. To accomplish this Ada allows me to define the fields of my record to specific words in memory.

Code:
word = 4;
type Msg_Type1 is record
x: Some_Type;
y: Another_Type;
z: Another_Type;
end record;

[Code] ....

View 5 Replies


ADVERTISEMENT

C++ :: Array Manipulation Of Messages?

Mar 25, 2014

Basically i need to encrypt a message into ascii values & i also need to allow the user type some ascii values thus decrypting the values into characters that are placed within the code.

#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
using namespace std;
#define Q 2000
void main(){

char array1[Q]={"A gentle, dull flickering flame, burns in the marble hearth. Its dim light scarcely illuminates the small, cozy room with its quiet elegance. The dismal light plays softly causing shadows over the solitary figure of a wooden desk at which Allen was roaming through his memories. Thinking back in the past where he once had a friendship which was out righteously incredible. She was the girl of his dreams, in a way which she had everything he had ever sought out in a beautiful and clever girl. Most of all she had his heart. Her style was incredible in the way the outfits she would wear would match perfectly giving a deep vibrant lively feeling."};

int S[Q];
char S1[Q];
int x;
int i;
char e, d;
cin>>x;
if(x=d){
cin>>Q;
for(i=0;i<array1[Q];i++)
cout << S[i]<<endl;
for(i=0;i<array1[Q];i++)
cout << S[i]<<endl;
}

View 18 Replies View Related

C++ :: Struct Alignment Across Compilers And Operating Systems

Oct 5, 2013

I am working on extending an application that features a (rather old) plugin system. The plugin system is designed to work on x86 only, but support any and all compilers on windows, linux and also OSX.

My goals are now to

1) extend the plugin framework in a backwards compatible way
2) port it elegantly to x64

So far so good.

The plugin subsystem essentially exports a bunch of SDK function like this:

Code:
extern "C" CDECL int somefunc(int a, int b);

Which can be used by the plugin, and expect the plugin to export some function in return. When a struct is supposed to be send to the plugin, the syntax of the system goes like this:

Code:
extern "C" CDECL int RequestStructField(int field, int structhandle);

So the struct isnt handed over via a pointer, but every field has to be requested individually! From what I can tell from the comments, the developer was afraid there might be problems exchanging structs between different compilers, alignment and all.

I would like to tear down this limitation, and pass pointers to structs to plugin directly. Or better: allow the plugin to give me a pointer to an empty struct which i subsequently fill.

However, i have no control over the compiler or language used to write the plugins. Quiet some plugins are written in Delphi, some even in MASM ... both would have to support this way of passing structs.

the question is: does that work?

I have looked at other plugin systems, but they either use entirely different ways (XPCOM) or are limited to a single platform or compiler.

Some of them have a note stating that the plugin must be compiled with "byte-aligned" structs.

x86 and x64 plugins are two different stories, x64 version of the app does NOT have load x86 plugins. I dont expect there to be too man problems (right?). But we'll see, i guess.

View 13 Replies View Related

C :: Initialize Data Member In Struct

Mar 28, 2013

I was looking at some linked list material and was wondering something. Can you initialize a data member inside a struct like in C++? i.e.

Code:
typedef struct node
{
int data;
struct node * next = NULL; // this is the line in question
} LLnode;

View 3 Replies View Related

C :: Cannot Assign Struct Member Values

Feb 13, 2015

I'm a C beginner trying to assign struct member values to other struct members to create a list.

I've tried dot notation, pointer notation, strcpy, memcpy, memmove and normal assignment.

Nothing has worked.

cust_list.h

View 5 Replies View Related

C++ ::  Static Member In Struct Array?

Jun 25, 2013

Here's the definition of my struct:

struct Speaker {
static int numElem;
string name;
int number; // Phone
string topic;
float fee;
};

// IN main() FUNCTION
Speaker s[10];

The goal is for numElem to keep track of how many of the 10 elements are in use. However, I'm not sure the proper way to access the element, if it's even possible.

View 7 Replies View Related

C/C++ :: Segfault When Accessing Member Of A Struct

Mar 18, 2014

The program I'm working on is a very basic relational database. I've isolated my problem for simplicity. I get a segfault right here when I try to access db->relationCount. I tried printing db->relationCount from within loadDB and that worked,

[code]
loadDB(db, configFile);
printf("%d",db->relationCount);
fflush(stdout);

View 5 Replies View Related

C/C++ :: Assigning Value From Struct Member To Outside Structure

Jun 20, 2013

I have the code bellow, and i print the data but cannot assign it to global variable.

struct frequency_data {
 char frequency[10];
 int32 frequenca_mesatare;
 int16 PWM_F;
 int32 PR2;

[Code] ....

View 5 Replies View Related

C :: Set Struct Member Variable For Structure Inside Def

Mar 12, 2014

This is with Linux gcc

Code:
typedef struct _a
{
int id;
} a;
typedef struct _b
{
a my_a;
my_a.id = 1; // error: expected specifier-qualifier-list before "my_a"
} b;

I get error: expected specifier-qualifier-list before "my_a"

I must set the id for the kind of struct created inside the struct def because main() will be casting based on this id. Thats how I will know which structure b contains by it's id, there could be hundards of different structs with different values I will cast to the correct one and know it's members by it's id. How do I ?

View 10 Replies View Related

C++ ::  How To Get Relative Address Of Member Of Class Of Struct

Apr 2, 2014

How to get relative memory address of members of Class or Structure ? I want to auto scan the members of Class/Struct, and show the address/value like the "watch window" in debug mode of popular C/C++ IDE software.

View 2 Replies View Related

C/C++ :: Declaring Constant Struct As A Member Of Class

Oct 2, 2014

I would like to have a unmodifiable standard of WAVEFORMATEX defined as a member of a class of mine. Something like:

class InputTest {
public:
const WAVEFORMATEX StandardWaveFormat;
public:
void TakeInput(WAVEFORMATEX pFormat);
};

Then in my cpp file to hard-code the values:

WAVEFORMATEX InputTest::StandardWaveFormat {
//Instantiate WaveFormat -- PCM standards
StandardWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
StandardWaveFormat.cbSize = 0; //extra information sent over stream. Usually ignored in PCM format.

[Code] ....

I get the following errors starting with the header file:

Error1error C2146: syntax error : missing ';' before identifier 'StandardWaveFormat'
Error2error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

both associated with the "const WAVEFORMATEX StandardWaveFormat; " line.

Here's a link to the WAVEFORMATEX struct: [URL] .....

Then the cpp source code is probably way off. Let me know if you'd like to see the errors associated with that.

View 11 Replies View Related

C++ ::  assigning To A Member From Struct Obtained By Overloaded Operator

Jan 27, 2014

I'm trying to assign a value to a member of a struct that I called via an overloaded [] operator. I have the following code for the struct:

typedef struct {
float r, g, b, a;
float operator [](int pos) {
switch (pos) {

[Code] ....

And what I wish to do is

MyStruct a;
a[0] = 0.5;

Is it possible with a struct? How to express this to search engines so I haven't been able to find anything about it. If this is not possible with a struct, is there a way to define something that can do all the following things:

SomeStruct test = {0.5, 0.5, 0.5, 1};
test.g = 1.0;
test[0] = 0.0; // test[0] would be equivalent to calling test.r
float somevalue = test[3]; // test[3] would be equivalent to calling test.a

I hope I've been sufficiently clear.

View 2 Replies View Related

C# :: Setup Not Working In Other Systems With Other SQL DB Server

Mar 7, 2014

I developed one windows application in c#.net , this application is not working when i installed the setup in another system with another sql database server-r2. How can solve this. here i had attached my code for reference.

App.config file

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SqlCon" value="Data Source=.sqlexpress;Initial Catalog=aathi;Integrated Security=True;Pooling=False"/>
</appSettings>
</configuration>

[Code] ....

View 3 Replies View Related

C++ :: Standardizing Size Of Float Across Multiple Systems

Jan 4, 2015

I'm currently writing a cross-platform on screen keyboard application that highlights keys on the screen as you type them. My approach was to use an image of a keyboard and layer semi-transparent sprites over each key on key events, and as a consequence I needed to map out precise positions of each of these sprites relative to the background image.

The issue became how to load those positions into my application during runtime? My solution was to use excel to make a .csv of all the x-y coordinates, but instead of just deploying the .csv with my application I decided to write a quick app that parsed each line of the csv for coordinate pairs and write those floating point numbers to a binary file instead. That way the end user can't easily edit the coordinates of the sprites.

Now on to my question. The way I load the data into my application is by this method:

#include <fstream>
#include <vector>
/* other includes */
/* ... runtime code ... */
std::vector<float> pixmapPosData;

[Code] ....

This works fine on my system, but what if sizeof(float) has a different length their system? Then this function could throw a read access violation towards the end of the file (since the .bin file is exactly 508*sizeof(float) bytes long on my computer), and not to mention the coordinates would be meaningless. Is there any way to avoid this? Or maybe I just just suck it up and deploy a .csv file?

View 3 Replies View Related

C :: Floating Point Number Manipulation

Mar 3, 2013

I am having trouble understanding the mantissa of a floating point number. I have divided up the floating point number into the sign bit, the exponent and the mantissa, I have found the exponent, but I am not sure what to do with the mantissa? From what I have gathered so far i divide the mantissa by ten until I get a number between 1 and 10. after that i convert the number into a decimal with everything after the decimal point (or radix) being a fractional number. But when I do that on paper I dont get my intended number. How do i put the exponent and mantissa together to make a decimal from my floating point?

ex. input is 00111010000111111111011000001000
sign is 0
exponent is 01110100 which is 64+32+16+4-127=-11
mantissa is 00111111111011000001000 which would be 1.11111111011000001

When i convert that i get 1.99756622314 i dont know what to do with the -11 exponent and the answer i want is 6.1e-4

View 1 Replies View Related

C++ :: VGA VRAM Manipulation For Graphics Modes?

Jan 20, 2013

I'm trying to find the errors in my emulation of VGA VRAM concerning graphics modes.

(I'm testing it by doing plotting of all colors from x=0 to x=xsize-1 (where the color is relative, so 0=0 and xsize-1=maxcolor (in the case of 16 colors it's 15, etc.)))

VRAM Graphics management:

#include "headers/types.h" //Basic type support!
#include "headers/hardware/ports.h" //Basic PORT compatibility!
#include "headers/hardware/vga.h" //VGA data!
#include "headers/mmu/mmu.h" //For CPU passtrough!
#include "headers/hardware/vga_screen/vga_displaygeneration_crtcontroller.h" //For virtual width in bytes within VRAM!

[Code] .....

View 1 Replies View Related

C++ :: Transpose Matrix Array Manipulation

Jan 3, 2013

Array Manipulation - Transpose of a Square Matrix: This program reads a matrix (two dimensional array), displays its contents, transposes it and then displays the transposed matrix. And here's the code

Code:
#include <iostream.h>
const int arraySize = 3;
void readMatrix(int arr[][arraySize]);
void displayMatrix(int a[][arraySize]);
void transposeMatrix(int a[][arraySize]);

[Code] ....

When I compile the program it says 'mail' must return 'int' I think everything is right...

View 2 Replies View Related

C++ :: Getting A Large String Vector For File Content Manipulation?

Dec 10, 2013

I need a large string vector for file content manipulation.

v1.max_size() gives me 153 391 689.

But if I make a test by looping a vector pushing back strings it crashes around 16 - 26 000 000 though I still have a lot of ram (1GB left).

How come and why isn't vector size limited by ram instead?

View 11 Replies View Related

C++ :: Input / Output Text File Manipulation Not Working

Mar 24, 2013

Why my output screen for this program does not want to stay open. It only opens for a split of a second and it's gone. The program is supposed to take numbers from a input file and display and save the manipulation in the output file. Here is the program.

Code:
#include<iostream>
#include<fstream>
#include<iomanip>
usingnamespace std;

[Code] ....

View 6 Replies View Related

C++ :: Convert QT String Manipulation Function To Work With Strings?

Feb 15, 2012

I have the following function I would like to convert to work with std:string. I don't understand QT strings at all.

Code:
void FromHexString(const QString &hexText, void* pData, int dataSize) {
for (int i = 0; i < hexText.length(); ++i) {
bool ok = false;
((uint8_t*)pData)[ i ] = hexText.mid( 2*i, 2 ).toInt( &ok, 16 );
}
}

View 1 Replies View Related

C++ :: Program That Simulate Card Game - Array Manipulation

Apr 26, 2013

Consider a program that simulates a card game, with multiple player hands and a deck to draw from. Each hand can use an array to represent the cards it contains; sometimes it is useful to also declare an additional variable for each hand (or deck) indicating exactly how many cards are present.

1) Describe a simple function that would manipulate both the array representing a hand and the number indicating the size of the hand.

2) Describe a simple function that might be able to manipulate the array without referring to the hand size variable at all.

3) Generally, if the array was passed as a parameter to a function, how often would the hand size be included as a parameter?

View 2 Replies View Related

C# :: Sending Messages To Log In And Password

Apr 20, 2014

I wanted to make an program which is sending messages to log in and password, but instead of message it gives me "System.Windows.Forms.TextBox, Text: AND HERE MY TEXT I WANTED.

View 9 Replies View Related

C++ :: Template Class For Matrix Manipulation - Expected Initializer Before Constant

Jan 29, 2013

I wrote a template class for Matrix manipulation. The compiler cannot compile the source and complains

Matrix.h:144:41: error: expected initializer before ‘const’

What is the problem of the code enclosed below?

#ifndef MATRIX_H
#define MATRIX_H
/**
* @file Matrix.h
*The Matrix template class written for simplify the matrix manipulation.
*/

#include <cassert>
using namespace std;
template<typename T>
class Matrix {
int rows,cols;

[Code] .....

View 6 Replies View Related

C :: Connecting To SMS Server And Send Messages

Nov 11, 2013

I'm currently in the middle of designing a program for some project. one part of the program is to send reminding SMS messages to the employees.

I have already subscribed to a SMS provider and they gave me an access to a control panel (aspx). But now I'm wondering how will I be able connect to the SMS server and be able to send messages?

View 11 Replies View Related

C/C++ :: Schedule Sending Of Messages From A Process

Mar 18, 2015

I am new to this area and have the requirement like:

1) A running process wants to send message based on event arrival.

2)the process checks if event is critical

3)if critical then it has to send message immediately ,else send after time t.

4) The process is continuously process the events . so once it knows the event is not critical and has to send message later it has to proceed with its normal operation.. only when time 't" comes it has to come and send message.

View 4 Replies View Related

C++ :: Possible To Alter Error Messages For A Particular Line?

Apr 23, 2012

Is it possible to alter an error message for a particular line if you think it might fail compilation? GNU specific stuff is okay. The reason I want to do it is because I have this code.

Code:
template <size_t S>
struct assertion{}
int main(){
{
volatile assertion<sizeof(config::input)> asrt = assertion<sizeof(config::output)>();
}
}

If the arrays config::input and config:utput are different sizes, I want it to be clear that that's what needs to be fixed. Is there an __attribute somewhere that will allow me to do that?

View 2 Replies View Related







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