|
That's a solution but you'll need to be sure that the data in the buffer has the same format as your structure. What I mean is that in your structure, the members will be aligned on a 8 bytes boundary (but you can change that). So, if it is not the case in your buffer, you will have some problems.
|
|
|
|
|
Alignment can be adjusted and by default uses natual alignment up to 8 byte PODs. VC doesn't use 8 byte alignment.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
Alignment can be adjusted and by default uses natual alignment up to 8 byte PODs
Yes, that's what I said .
Tim Smith wrote:
VC doesn't use 8 byte alignment
Err, pretty sure that it does. I had a bug two years ago because of that (loading data from a file and memcpy it to a struct) and I spent a lot of time to solve it. And it was because of the member struct alignement that was to 8 by default.
|
|
|
|
|
actually the thing isthat we have stored data in a buffer.....now we declared an aaray of a structure to copy that data.abb i dont know that how do we specify no of bytes using bitwize operator.
|
|
|
|
|
you cannot copy a whole group of varialbes into a structure, except at its initialization.
the rest of the time, you'll have to point each member of the structure to affect it...
this is because generally, the members of a structure may be by side, but not necessarily...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Try being more specific. How is the buffer declared? What's its content? In what format? How is the structure declared?
Withouth such details, the answer can only be as vague as your question:
Q: how do we copy data from a buffer to a structure?
A: you extract pieces of data from the buffer and put them into the appropriate fields of the structure.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
i have read a log file through buffer.it tells us that how many calls are in the log file!now wat i have to do is that i have to copy the certain bytes of each call in a structure. lets suppose 364 bytes i have to copy of each call!
|
|
|
|
|
now tell me how do we extract peices of data from buffer?
|
|
|
|
|
see this[^] posted on the forum yesterday...
it's quite similar as you extract datas from a buffer...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
we have character data in our main buffer and also we need to pack two bytes of data from our main buffer into 1 byte of data in our small buffer.how we'll do this
|
|
|
|
|
hey hey hey,
please calm down, otherwise, noboody will help you...
moreover, you question is far from being clean... what are those buffers ? i've understood you had only one, and now, you talk of two buffers !
i think the best way to make us understand is to provide so little schemas (into <pre></pre> tags) and some code...
explicit also you question clearly, with what you have, what you want, what don't work and what error messages are sent.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
actually i'm in office.....n m tensed as well...oki let me explain again that i've read a file and stored its data in buffer righttt! now i have to copy some specific bytes from that buffer to a structure.the thing is that the data in my file is stored in characters.means there is one character at each index.and i have to pick two characters at a time and store it in a structure....right now plzz tell me how we'l do this.......
|
|
|
|
|
If you could post your structure, this would help a little bit more. You have to understand that we cannot see what's on your screen so we have to guess what you want to do with the little clues you gave us.
Ok, in which 'format' you want to store this two characters ? Is it an integer or a string ?
If it is a string, you can simply do that:
struct.MyString[0] = Buffer[Index];<br />
struct.MyString[1] = Buffer[Index+1];
If it is an integer, you could do that:
char Temp[3];<br />
Temp[0] = Buffer[Index];<br />
Temp[1] = Buffer[Index+1];<br />
Temp[2] = '\0';<br />
struct.MyInt = atoi(Temp);
If it doesn't help, try to be more specific and POST CODE !!
|
|
|
|
|
Nadia,
Could you please provide us your structure prototype?.
And I also intersteded in your buffer data?. How they are categorised/delimited from each item?
What do you mean by big buffer and small buffer ?
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
enough !!!
there are too many posts on CP Forums that are just reposts of what's just been said right before...
Cedric and I already asked what you just posted there. did you bother read the answers before making yours ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
What you understood by all your post...
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
I need to run my software (dialog based in VC++ format) in both GUI mode and CLI mode. If the user chooses to run the program by clicking the icon all the program's functionalities must run in GUI mode. if the user chooses to run the program in the command line, all the program's functionalities should run in in CLI mode. If it is running in the command line it should also perform i/o operations.
Please help me...
I really need help as soon as posible...
|
|
|
|
|
What's with all those emoticons?
I think you'll need to use a command line parameter to differentiate the different invocations. For example, "yoursoft.exe" invokes the GUI mode, but "yoursoft.exe -nogui" runs withouth the GUI. I'd put the common functionality in a lib. The lib can be linked to a GUI exe (say "yoursoftGUI.exe") and also to a console app (say "yoursoft.exe"). Then, in the console app you just continue as a console program or call yoursoftGUI, depending on the command line parameters.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
thanks...
there is only one problem left i cant perform console i/o.
can you help with with this.
thanks
|
|
|
|
|
There are Windows API to attach Console to your window.
Please refer AllocConsole() and FreeConsole() method. Those API will create console window for your application. Then you can also perform read/write operation using STDOUT, STDIN (GetStdHandle etc)....
Please let me know if you encounter any problems..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
thanks...
I'll let you know if i encountered some problem...
thanks again...
|
|
|
|
|
Hello,
We are trying to implement the file access using scattergather mode.
Can anyone give me an example of how to use this, open, read, write...
thank you
Uday
|
|
|
|
|
I've never used it, but the API is straight forward, just read ReadFileScatter() docs.
As you don't specify the scenario for use, here's another 2cents:
It's use, from what i see, would only be of real use in reading/writing custom database files that are page aligned.
Using ReadFile()/WriteFile() in overlapped mode is a much more usefull general method of file I/O.
(or even memory mapped files for that matter)
...cmk
Save the whales - collect the whole set
|
|
|
|
|
hello,
I wanted to know why can't we use OnInitMenuPopUp() function in dialog based application?In my dialog application when i right click on dialog name ;in the list of windows handler i don't get WM_INITMENUPOPUP handler.
Why so?
thanks
|
|
|
|
|
Hello,
In my Application I made a treeview that displays the system directory structure - like the tree on the left in windows explorer. I also have an Open button that opens a file (OpenFileDialog). So basically my user can browse for a file through the directory tree (the treeview) or through the Open button.
My problem is this - If the user chooses to use the Open button to open a file, when she/he does so, I want the treeview to reflect the location of the opened file. That is, to expand appropriately from the root and select the folder that contains the open file.
So far I have tried several approaches but none led to a solution ...
1) I looked in the .NET Framework, in TreeView class, for a function that takes a full path and is able to expand to and select the resulting directory. I could not find such a function.
2) I was successfull in parsing the full path I got from the open file dialog window into directories. However I found no functions in the .NET Framework that could help me track from the root to the last directory of the treeview.
If anybody knows how to solve this problem or has an approach to solving it, I would appreciate hearing it greatly.
TraileR ParK LifE 4Ever
|
|
|
|