Sponsored Content
Top Forums Programming Storing C++-struct in file - problem when adding new item in struct Post 302569813 by DreamWarrior on Tuesday 1st of November 2011 03:51:29 PM
Old 11-01-2011
Agreed with Corona, and I was going to make the same statement, but not seeing the rest of the code, and under the assumption it works, I figured maybe it was memory mapping the file to some fixed address location. That'd allow the pointer values to be stored and actually work so long as they only pointed to an address within the memory mapped region.

That said, I have no idea if the code is actually doing this. And, I must admit, for a properties file it's fetched.

As for the OP, I think you're generally misguided regarding what the code is doing. That struct is unlikely to be stored directly in the file. I'd dig a little deeper in the code and figure out what is reading and writing the file's data.

Better, why don't you just post what the file looks like; with that information we could probably immediately tell you whether or not that exact structure is stored verbatim in the file.
 

10 More Discussions You Might Find Interesting

1. Programming

struct tm problem

I receive an integer as argument for a function. within function definition i want it to be of type struct tm. eg.. main() { int a; ...... } function(...,..,a,..) int a; { struct tm tm; if(!a) ^ time(&a); ^ ... (4 Replies)
Discussion started by: bankpro
4 Replies

2. Programming

Problem accessing struct member

I have a struct as follows... struct A { int a; ucontext_t X; //ucontext_t is another structure } How do I define a pointer to the above structure variable X of the type ucontext_t from within another function? eg. void foo() { struct A a; /////WHAT COMES IN... (1 Reply)
Discussion started by: jacques83
1 Replies

3. Programming

writing binary/struct data to file

I am trying to write binary data to a file. My program below: #include <stdlib.h> #include <stdio.h> struct tinner { int j; int k; }; struct touter { int i; struct tinner *inner; }; int main() { struct touter data; data.i = 10; struct tinner... (4 Replies)
Discussion started by: radiatejava
4 Replies

4. UNIX for Advanced & Expert Users

problem with netfilter hook function struct skbuff *sock is null..

iam trying to built a firewall.so i have used netfilter for it. in function main_hook sock_buff is returning null and in my log file continuously "sock buff null" is printed plse help to solve this problem.. (using print_string iam printing strings on current terminal (terminal we ping)) ... (1 Reply)
Discussion started by: pavan6754
1 Replies

5. UNIX for Dummies Questions & Answers

How to access a struct within a struct?

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)
Discussion started by: unbelievable21
1 Replies

6. Programming

Compiling virtual network adapter driver problem (net_device struct)

Hi, I found on linuxgazette.net/93/bhaskaran.html page very useful sample of virtual driver (not connected to real hardware). I try to compile it with no effect. So: I got fresh Ubuntu 9.10 (kernel 2.6.31-14) My source is saved in networkAdapter.c file in /usr/src/myModules directory. I... (21 Replies)
Discussion started by: Chrisdot
21 Replies

7. Programming

Can't assign struct variable in header file

Hi guys. I have a header file including a structure like this: typedef struct { int index = -1; stack_node *head; } stack; But when compiling with cc it shows error at the assignment line (int index = -1): error: expected ‘:', ‘,', ‘;', ‘}' or ‘__attribute__' before ‘=' token... (1 Reply)
Discussion started by: majid.merkava
1 Replies

8. Programming

Problem defining a struct

I have the following code and getting the compilation errors baseLib/DynBaseObj.h:80: error: expected constructor, destructor, or type conversion before ‘(' token baseLib/DynBaseObj.h:89: error: expected constructor, destructor, or type conversion before ‘(' token baseLib/DynBaseObj.h:101:... (0 Replies)
Discussion started by: kristinu
0 Replies

9. Programming

search file and put into struct

hi everybody, I need some help with some programming. I need to write a file that can search in a text file and read the whole line into a struct. the struct = struct Transistor { char chType; char chFabrikant; float fPrijs; enum Transistor_Behuizing { empty,TO18, TO39,... (8 Replies)
Discussion started by: metal005
8 Replies

10. Programming

Python Results Converted To C Struct Header File

I created python code that produce output in the form of: moses-red-sea=1.00.03 genesis-snake=2.03 deliverance=5.0.010 I need to take this output and create a "C" header file and have it look like this: struct { char *name; char *fixed_version; } filename_versions... (7 Replies)
Discussion started by: metallica1973
7 Replies
iomap(7)						 Miscellaneous Information Manual						  iomap(7)

NAME
iomap - physical I/O address mapping SYNOPSIS
DESCRIPTION
The mechanism allows the mapping (thus direct access) of physical I/O addresses into the user process address space. For PA-RISC machines, the physical I/O address space begins at and extends to The special (device) files for devices are character special files using the dynamic major number allocation scheme. The minor number for devices is of the form: The physical I/O address is formed by prefixing 0xAAAA with 0xF, and by appending 0x000 (this forces the I/O address to be page-aligned). The size of the region to be mapped is given by the expression M*(2^S) 4K pages. For example, the minor number for a device starting at that occupies 64MB is The driver must be explicitly added to the file, the kernel rebuilt, and the system subsequently rebooted prior to first using I/O space is always mapped with both read and write access rights, regardless of the actual permissions on the device special file. Multiple processes can have concurrently a single device opened and mapped. It is the responsibility of the processes to synchronize their access. Successive calls to to map the same I/O space must be identical to the first mapping. Identical mappings have the same address and size. Note that a process can additionally share I/O space (mapped by with a kernel driver. However, this is only possible if the driver maps in the I/O space with user read/write access rights using the appropriate driver I/O mapping services. Any I/O space mapped by drivers with kernel read/write access rights cannot be concurrently mapped by processes using No or system calls are supported by the driver. The function is used to control the device. The following requests are defined in Map the device into user address space at the location specified by the pointer to which the third argument to points. If the argument points to a variable containing a null pointer, the system selects an appropriate address. then returns the user address where the device was mapped, storing it at the address pointed to by the third argument (see below). Multiple processes can concurrently have the same device mapped. Unmap the device from the user address space. shuts down the file descriptor associated with the device. If the close is for the last system wide open on the device, the device is also unmapped from the user address space; otherwise it is left mapped into the user address space (see above). WARNINGS
Be extremely careful when creating and using devices. Inappropriate accesses to I/O devices or RAM can result in a system crash. ERRORS
The address field was out of range, or the request was invalid. Not enough memory could be allocated for the mapping. Device was already mapped and this mapping was not identical to the initial mapping (same address, size and access rights). Read and write calls are unsupported. No such device at the address specified by the minor number. Required resources for mapping could not be allocated. Inappropriate request for this device type; fildes is not a file descriptor for an device file. EXAMPLES
Consider the following code fragment: ... ... where is an open file descriptor for the device special file and is the address originally requested by the program. If is a null pointer, the system selects a suitable address then returns the selected address in addr. If the value in addr is not a null pointer, it is used as a specified address for allocating memory. If the specified address cannot be used, an error is returned (see SEE ALSO
mknod(1M). OBSOLETED iomap(7)
All times are GMT -4. The time now is 05:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy