Groups | Search | Server Info | Login | Register
Groups > comp.lang.c.moderated > #407
| From | nwdpil <mkeput@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c.moderated |
| Subject | distributing data across a structure (new to c please help) |
| Date | 2012-08-09 20:32 -0500 |
| Organization | http://groups.google.com |
| Message-ID | <clcm-20120809-0001@plethora.net> (permalink) |
the ulimate goal is to read the MZ header from a binary windows pe file, which is simple enough. anyway the theory goes (and this is the bit i dont understand im new to c programming) i memcpy the data from the file ACROSS a struct. is this possible? i dont understand how to initialise and manipulate the struct. can i copy a set of data that is 16bytes long, to a struct with two 8byte children and will memcpy then distribute the data for me if i pass it pointers?
it sounds easy but im really struggling to get to grips with it. anyway heres a simple c program i wrote to demonstrate the concept. it fails with the error Run-Time Check Failure #3 - The variable 'x' is being used without being initialized.
for example i should be able to access string "00004444" with x->b; and "eeeeffff" with x->bb;
im on windows running visual c++ 2010 express, although im coding purely in c because i never saw the point in object orientated programming.
help please?
[code]
// pointblank.c : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
typedef struct _test {
char b[8];
char bb[8];
}; test, *ptest;
int _tmain(int argc, _TCHAR* argv[])
{
struct _test * x;
char* s[16] = {"00004444eeeeffff"};
memcpy (x,s,16);
return 0;
}
[/code]
i honestly dont get it, if you could spend five minutes coding it for me so i can learn from reading your code would be excellent. this is a large scale project im working on but im totally new to c so its a bit... odd for me. im trying to write a pe file disassembler (just so you know). why? why the heck not? - nwdpil
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Back to comp.lang.c.moderated | Previous | Next — Next in thread | Find similar
distributing data across a structure (new to c please help) nwdpil <mkeput@gmail.com> - 2012-08-09 20:32 -0500
Re: distributing data across a structure (new to c please help) James Kuyper <jameskuyper@verizon.net> - 2012-08-10 00:43 -0500
Re: distributing data across a structure (new to c please help) Dennis Yurichev <dennis_mailing_lists@conus.info> - 2012-08-20 14:17 -0500
Re: distributing data across a structure (new to c please help) Keith Thompson <kst-u@mib.org> - 2012-08-20 22:10 -0500
Re: distributing data across a structure (new to c please help) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-08-20 22:11 -0500
csiph-web