How to read data from files to structures(stru cture having more
elements)
Thanks in adavance
--
Posted via http://dbforums.com 2 2983
Originally posted by Burne C "krishna_v" wrote in message news:3150950.10 59105697@dbforu ms.- comnews:31***** ***********@dbf orums.com... How to read data from files to structures(stru cture having more elements) Thanks in adavance -- Posted via http://dbforums.com/http://dbforums.com
If you write the structure to the file by yourself and you have to read it later (on the same machine), try this method :
#include
/* some structure */ typedef struct mystruct_tag { int var1; int var2; long var3; }mystruct;
int main(void) { /* create a file */ FILE *fp = tmpfile(); mystruct mst1; mystruct mst2 = {10,20,30};
/* write the structure */ fwrite(&mst2,si zeof(mystruct), 1,fp);
rewind(fp);
/* try to read it back */ fread(&mst1,siz eof(mystruct),1 ,fp);
printf("The struct contain %d %d %d \n",mst1.var1,m st1.var2,mst1.v ar3);
fclose(fp);
return 0;
}
--
Posted via http://dbforums.com
Originally posted by Zoran Cutura krishna_v wrote: How to read data from files to structures(stru cture having
more elements)
That pretty much depends on how the data is stored into the file, which is what people call file formats. Note that structures cannot be portable written and read from a file as blocks, because they may include system dependent stuff like padding bytes. So if you're talking about structure data that is written to a file in binary as a block, you'll probably burn your fingers. Store every element of the structure as a value of its own and read it back is this.
-- Z (Zo**********@d aimlerchrysler. com) "LISP is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days." -- Eric S. Raymond
HI
Thank you.
--
Posted via http://dbforums.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Olivier Maurice |
last post by:
Hi all,
I suppose some of you know the program Redmon (type redmon in google, first
result). This neat little tool allows to hook up any functionality to a
printer by putting the file printed to the printer to standard in.
You have to provide yourself the program that does something with that data,
so I thought with some quick c/c++...
|
by: Magnus |
last post by:
allrite folks, got some questions here...
1) LAY-OUT OF REPORTS
How is it possible to fundamentaly change the lay-out/form of a report in
access? I dont really know it that "difficult", but listen up;
Reports, the way I look at them, all present data downwards, in this way;
TITLE
data
|
by: Erpman |
last post by:
I am trying to access the data with in a wav file. I am testing with very
small files in order to keep the code simple to start with.
Basically, im writing the entire wav file to a byte using a fileStream.
The problem is that when reading back the data word by word and printing the
results on a general form, once the data chunk header has...
|
by: jccorreu |
last post by:
I've got to read info from multiple files that will be given to me. I
know the format and what the data is. The thing is each time we run
the program we may be using a differnt number of files, with different
file names each time. So i'm writing into the code to ask the user how
many files, and what their names are. From each we'll read in...
|
by: arne.muller |
last post by:
Hello,
I've come across some problems reading strucutres from binary files.
Basically I've some strutures
typedef struct {
int i;
double x;
int n;
double *mz;
| |
by: Tyler |
last post by:
Hello All:
After trying to find an open source alternative to Matlab (or IDL), I
am currently getting acquainted with Python and, in particular SciPy,
NumPy, and Matplotlib. While I await the delivery of Travis Oliphant's
NumPy manual, I have a quick question (hopefully) regarding how to read
in Fortran written data.
The data files are...
|
by: MF AHMED |
last post by:
Hello,
I am facing problem writing an algorithm/codes. From a C program, I generated 100 data files, now I have to read those files having three columns each. Using every data of each line of all the 100 files I have to determine the average for all the three variables separately. Problem (again):
(1) Reading 100 data files
(2) There are...
|
by: blazedaces |
last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing and why I have to do it. Hopefully someone has a suggestion...
Alright, so I'm using a gps-simulation program that outputs gps data, like...
|
by: swetha |
last post by:
HI Every1,
I have a problem in reading a binary file.
Actually i want a C program which reads in the data from a file which
is in binary format and i want to update values in it.
The file consists of structures of type----
struct record {
int acountnum;
char name;
float value;
|
by: rka77 |
last post by:
Hi,
I am trying to make a Python2.6 script on a Win32 that will read all the text files stored in a directory and print only the lines containing actual data. A sample file -
Set : 1
Date: 10212009
12 34 56
25 67 90
End Set
********
Set: 2
Date: 10222009
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |