#define STRMAX 50
struct Person {
char sName[STRMAX];
int iAge;
};
typedef struct Person PERSON;
int main() {
PERSON *personen[1];
personen[0]->sName = "Pieter";
personen[0]->iAge = 18;
return 0;
}
This code generates an error on personen[0]->sName = "Pieter"; saying incompatible types in assignment. Why?
...
Is there an easy explanation for what this error means?
request for member '*******' in something not a structure or union
I've encountered it several times in the time that I've been learning C, but I haven't got a clue as to what it means.
...
#include <stdio.h>
#include <stdlib.h>
typedef int element;
struct cell {
element e;
struct cell *p;
};
typedef struct cell* CELL;
int main() {
CELL* p;
p = (CELL*) malloc (sizeof(struct cell));
p->e = 8; /* This ain't working */
*p.e = 8; /* This doesn't help anything either */
return 0;
}
I...
I have the following struct:
struct cell {
int nmbr;
struct cell *p;
};
I have created a chain of linked structs from this type. Every struct is connected to its predecessor through *p. If I decide to print all nmbrs with a recursive algorithm as shown below, how do I define the stop condition?
void write(struct cell* l) {
...
Hello,
I have a lot of data stored in bin format as a sequence of structs. I want to be able to read randomly any of the structs and modify it in C. I am trying with the following code but it doesn't work. Can someone fix it for me please?
Also, would it be possible to delete an intermediate struct from the file in between?
The code i...
I would like to flip from big to little endian this string:
\x00\x40
to have it like this:
\x40\x00
I guess the proper function to use would be struct.pack, but I can't find a way to make it properly work.
A small help would be very appreciated !
Thanks
...
According to TLD, tag bean:write must be empty, but is not org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:132) org.apache.jasper.compiler.Parser.parse...
I need to read a blob field from a database into a c# app.
However the blob field was written to the database by a Delphi App using the following method:
procedure WriteABlob(Blob : TBlobField; var Buffer; size : integer);
var
s : String;
begin
setlength(s,size);
move(buffer,s[1],Size);
Blob.Value := S;
end;
...
Can I assume a file generated with fwrite and read using fread is portable across different systems. 32bit/64bit windows,osx,linux.
//dumping
FILE *of =fopen("dumped.bin","w");
double *var=new double[10];
fwrite(var, sizeof(double), 10,FILE);
//reading
file *fo=fopen()
double *var=new double[10];
fread(var,sizeof(double),10,of);
And w...
I'm new to C#, so forgive this noobish question. I'm playing with a simple XNA game demo. I have a struct that I want to be available to several classes. It is defined as follows:
PhotonType.cs
using System;
namespace ShipDemo
{
public struct PhotonType {
public Color tint;
}
}
In another file in the same folder/namespace,...
This is a cut down example of a much larger project. You can see it here.
I have a header file containing the limits of the system time functions. Call it time_config.h.
#ifndef TIME_CONFIG_H
#define TIME_CONFIG_H
#define HAS_TIMEGM
#define SYSTEM_LOCALTIME_MAX 2147483647
#define SYSTEM_LOCALTIME_MIN -2147483...
If I have the following:
typedef struct _MY_STRUCT
{
int a;
float b;
} MY_STRUCT, *PMYSTRUCT
What does *PMYSTRUCT do? Is it now a pointer type which I need to declare or just a pointer to _MY_STRUCT which I can use?
I know that MY_STRUCT is a new type that needs to be used as follows:
MY_STRUCT str;
str.a = 2;
But what abou...
I’m trying to figure out a way to use nested global structs as a sort of API namespacing for my C library.
Specifically, I want to expose a single Primary ‘namespacing struct,’ that contains other such structs (such as Primary.Secondary), that themselves contain function pointers (Primary.Secondary.a_function()).
I’ve abstracted out th...
Suppose I want to pass a temporary object into a function. Is there a way to do that in 1 line of code vs. 2, with a struct?
With a class, I can do:
class_func(TestClass(5, 7));
given:
class TestClass
{
private:
int a;
short b;
public:
TestClass(int a_a, short a_b) : a(a_a), b(a_b)
{
}
int A() const
...
I'm trying to make a Trie data structure (school work) and I'm using a list which I've also made myself and works fine (tested) to store the N-nodes in the Trie.
Anyway, the problem is, every node is supposed to store a list of nodes so I can make my N-ary tree/trie but I've hit a snag...
When I'm debugging and going through the for lo...
I've looked at some code for BSTs and I can see that each node is a struct. Is this necessary?
...
How do you use a pointer-to-struct to get input that will be stored in a string variable? I thought simply passing pz->szCompany to getline() would behave the same as if I had used the . operator on a normal instance of Pizza (instead of a pointer-to), but when I run this program it skips over the company name prompt completely.
// Part...
How do I fwrite a struct containing an array
#include <iostream>
#include <cstdio>
typedef struct {
int ref;
double* ary;
} refAry;
void fillit(double *a,int len){
for (int i=0;i<len;i++) a[i]=i;
}
int main(){
refAry a;
a.ref =10;
a.ary = new double[10];
fillit(a.ary,10);
FILE *of;
if(NULL==(of=fopen("test.bin","w"...
I have the following code in C++ which I need to be able to call from C#:
struct Inner
{
double data1;
double data2;
};
struct Outer
{
double data3;
SAFEARRAY innerData;
};
int WINAPI ProcessData (Outer& outer )
{
...
}
I tried the following but it did not work What am I doing wrong?
[StructLayoutAttribute(LayoutKind.Sequent...
What is the difference regarding memory allocation and efficiency between using a struct with two fields and a pair?
...