Hi, i'm trying to copy a struct into a binary file using the unix instruction write, so i declare and fill the struct "superbloque" in one function "initSB" and then i pass the pointer to another function called bwrite (for block write) which calls write. The problem is that i call the function with a pointer to my struct and write only creates the file and doesn't write anything. I'm pretty sure the problem i have has to do with the pointers because when i execute
in bwrite function it says 1 and should be 48
Here are the important parts of the code:
I know there's a lot of information about this but i've been reading for two days and I can't figure out how to solve the problem.
Thank you very much for your help
Ricardo Galli
Sistemas operativos
Universidad de las Islas Baleares (Palma de Mallorca, Spain)
Hi, i'm trying to copy a struct into a binary file using the unix instruction write, so i declare and fill the struct "superbloque" in one function "initSB" and then i pass the pointer to another function called bwrite (for block write) which calls write. The problem is that i call the function with a pointer to my struct and write only creates the file and doesn't write anything. I'm pretty sure the problem i have has to do with the pointers because when i execute
in bwrite function it says 1 and should be 48
Here are the important parts of the code:
I know there's a lot of information about this but i've been reading for two days and I can't figure out how to solve the problem.
Thank you very much for your help
Ricardo Galli
Sistemas operativos
Universidad de las Islas Baleares (Palma de Mallorca, Spain)
if pointer_to_the_struct is a pointer to the structure, then *pointer_to_the_struct is the first byte in the structure. so you a integer of 1
you should try
printf("%i",sizeof(struct xxx))
and this will get you the real size of the structure, and that's what you want
Hi,
I have received an application that stores some properties in a file. The existing struct looks like this:
struct TData
{
UINT uSizeIncludingStrings;
// copy of Telnet data struct
UINT uSize;
// basic properties:
TCHAR szHost; //defined in Sshconfig
UINT iPortNr;
TCHAR... (2 Replies)
Hello All,
I am having this issue...where I am actually having hard time understanding the problem:
The code is as follows:
#include<iostream.h>
void fxn(char*** var)
{
int i =4;
*var = (char**)malloc(i*sizeof(char*));
for(int j =0; j<4; j++)
{
*var = "name";
cout<<*var;... (6 Replies)
In a well-known book on the C language, there is an example of an efficient method for using a struct member as an argument to a function. (I'm a C noob, but I believe the correct terminology might be: use call-by-reference instead of call-by-value.) The function is printf.
Anyway, here's a... (5 Replies)
I am trying to work out the best syntax for a relatively simple operation. The goal is to declare an instance of a struct and pass it around to be populated and have the data manipulated. There is an extra wrinkle in that the functions are in different src files.
The main is simple,
#include... (5 Replies)
Can someone tell me how to do this?
Just a thought that entered my mind when learning about structs.
First thought was:
struct one
{
struct two;
}
struct two
{
three;
}
one->two->three
would this be how you would access "three"? (1 Reply)
EDIT: Nevermind, called a friend who is good at this stuff and he figured it out :D
Hi all,
So I'm trying to teach myself to write programs for unix in c. I am currently creating a program, and I need to pass a struct through a pipe, but I can't figure out how.
The struct I want to pass... (0 Replies)
Hi All,
My latest assignment (practice not coursework!) is to write prototype interactive exam/test console application. I've used structs to store the question information (not sure if this was the best way to do it?) and I have the following code that outputs each question and it's possible... (0 Replies)
I write kernel module with kernel threads using
linux/kthread.h on 2.6.* kernel
I tried to passing data between two kernel threads
with data argument of kthread_run( fun, data , NAME );
but this is not work I dont know why. I tried many possibility
and nothing works.
So I thought that... (0 Replies)
I am using a structure defined as follows
struct gene_square
{
double *x;
double *y;
};I have class, with a member function which is a pointer of this type:
gene_square* m_Genes;I am allocating memory in the constructors like this:
m_Genes = new gene_square;
for (ii=0;... (1 Reply)
Dear friends,
can anybody pls tell me how to pass FILE pointer in c. I am so confused .. :confused:
suppose I ve two function
1. file_open()
2. read_line()
I want to call these function from main() function and in file_open() function it will open that file and in read_line()... (5 Replies)