|
struct
{
char szName[25];
char szAddress[25];
char szCity[20];
char szState[5];
int nZIP;
int nAge;
} Demographics;
FILE *pFile = fopen(..., "wb");
fwrite(&Demographics, sizeof(Demographics), 1, pFile);
fclose(pFile);
...
FILE *pFile = fopen(..., "rb");
fread(&Demographics, sizeof(Demographics), 1, pFile);
fclose(pFile);
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Also the structure need to be #pragma pack/unpack ed
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Possibly, depending on the layout of it. In the example I provided, packing was not needed.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi again...
Thanks for d info...I guess I've got d method rite after all. But I couldnt seem to get all d data stored correctly upon reading the binary file.
Here's how I did it...
struct{
...
} Demographics;
Demographics demo = new Demographics [1000];
FILE *pFile = fopen(..., "wb");
fwrite(demo, sizeof(Demographics), 1, pFile);
fclose(pFile);
...
FILE *pFile = fopen(..., "rb");
fread(demo, sizeof(Demographics), 1, pFile);
fclose(pFile);
The value of '1' in fwrite(...) should reflect the no of records I have in d struct rite? But how do i ask the program to detect the it's value upon opening the file? Is there a function that can do that? Or do I have to create a header to the file to specify the number of records in d file?
Thanks again...
Rgrds.
|
|
|
|
|
Your code is incorrect. The variable Demographics is not a pointer so using new is in error. If you want 1,000 of them, simply use:
struct
{
...
} Demographics[1000]; Ming Yan wrote:
The value of '1' in fwrite(...) should reflect the no of records I have in d struct rite?
Correct.
Ming Yan wrote:
But how do i ask the program to detect the it's value upon opening the file?
If the size of the structure is 78 and the size of the file is 468, you know that there are 6 records.
Ming Yan wrote:
Or do I have to create a header to the file to specify the number of records in d file?
There's nothing wrong with this idea.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Is there any way to hide the drive letter from MyComputer. Is there any such API or method exists ???
Imtiaz
|
|
|
|
|
|
Hai all,
i was just practicing Layered Windows. So i created an MFC dialog based application and then proceeded. But when i try to call SetLayeredWindowAttributes () function, i got an error that the compiler cant find the function. When i look MSDN, the function is defined in windows.h and as its an MFC app, i think that there is no need for including windows.h header file.
But my compiler is stilling telling the error that it cant find the function. I had latest platform SDK installed and the Include path of visual studio is also updated. Im working in Windows XP.
Please help me.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
don^t know which MSDN library you looked at but mine says it is declared in
wingdi.h
AND you need to link to the library user32.lib
hope this helps you
|
|
|
|
|
Thanks for the reply. But the solution was not that. Just now i got the solution.
I searched the header files for SetLayeredWindowAttributes constants and found that they are only defined if the _WIN32_WINNT is >= 0x0500
#if(_WIN32_WINNT >= 0x0500)<br />
#define WS_EX_LAYERED 0x00080000<br />
<br />
#endif /* _WIN32_WINNT >= 0x0500 */
so i just added
#define _WIN32_WINNT 0x0500
and it worked...
And i dont know whether its the right method.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Can anyone give me a broad overview of skinning through the use of XML files? Any help would be greatly appreciated. Thanks.
|
|
|
|
|
XML only holds the skin information... Skining is done my Visual C++.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Who can advice me about website that teach about C++ Programming On Mobile
I use CodeWarrior on Symbian OS
Thank you very much
|
|
|
|
|
You should visit NewLC-website. It is dedicated to Symbian OS development and covers a few of the platforms available.
You cain find it from: http://www.newlc.com/[^]
Alternatively, you can use Visual Studio. There are instructions on how to do this around the Net. Developing for the Symbian OS with C++ is, for some reason, troublesome. Most of the SDK implementation ideas are extremely bizarre
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Im going to make a console project... don't ask... and I need to add command line arguments, im using windows xp, and somehow when I add the command line arguments to the end of the filename e.g. somefile.exe /something it says "/" and a bunch of other characters aren't alowed to be used... has windows xp completely taken off command line arguments?? sry its just that the last time I had command line arguments to one of my programs was when windows '98 came out.
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
#include <stdio.h>
int main(int argc, char** argv)
{
for (int i = 0; i < argc; i++)
printf("Arg %d = %s\r\n", i, argv[i]);
return 0;
}
This small C program will dump the args. The process of receiving args for console apps hasn't changed a bit
|
|
|
|
|
Oh yeah. If you're wanting a string with spaces, enclose them in quotes to get a single argument, e.g., long filenames with spaces:
<nobr>someprog.exe /v /n:5 "c:\my program data\my file data.txt"
The above yields 3 arguments passed to someprog.exe, plus somearg.exe itself.
arg0 = someprog.exe
arg1 = /v
arg2 = /n:5
arg3 = c:\my program data\my file data.txt
|
|
|
|
|
are you doing this on windows xp.. because for me it says / and some other characters are illegal to use
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
Hi!
I face a trouble, pls help me.
I wanna write a plugin for photoshop, but it call my plugin dll with a HFILE handle. But I should know the filename. Is there any way to get the file name from HFILE?
Thank you!
|
|
|
|
|
|
I have written a sample application to catch the WM_DEVICECHANGE message and it works well.
Now I tried to move the same functionality into a service so I create the service and the service creates an instance of a class which I defined that extends CDialog (called CMessageHandler).
CMessageHandler m_MessageHandler;
m_MessageHandler.Create(HIDDEN_DIALOG, NULL); {This returns TRUE, I checked}
CMessageHandler is supposed to handle WM_DEVICECHANGE event but it doesn't. I have declared it in the message map and I have created the necessary OnDEviceChange function but the messages never seem to be caught. I'm sure I'm doing something really stupid here.
Any help would be greatly appreciated.
|
|
|
|
|
have u checked the service actually receives messages?
"there is no spoon" biz stuff about me
|
|
|
|
|
I had posted a question in this forum earlier and was told that a service could receive messages indirectly if I created a window to handle the messages.
Would a window normally start receiving messages after the Create() method is called or should it be visible in order for it to receive messages?
Am I creating it right?
Thanks for your help
|
|
|
|
|
Hello there. I have read a message that you posted in this forum that u have written a sample application to catch the WM_DEVICECHANGE message and it works well.
I was wondering if you could e-mail to me a sample of the above application as I am interested in implementing that same function.
Also, would you happen to know of any working samples/examples that have implemented the OnDeviceChange() function? If you do, it would be great if you could lead me to/send me those sources. I hope u can help.
RaYDyO
|
|
|
|
|
Why does this take thirty or more seconds to run on a 1.5ghz 128mb machine?
Also when it runs this section of code (without sleep(1) after the addition) it brings the CPU up to 99 (its running in a thread)
This really makes no sense
It runs through somewhere between 7000 to 8000 entries:
CString m_strNewWordSection;
for (i=0; i<arWLSize; i++)
{
m_strNewWordSection+="\r\n\t<word_data><word>"+
m_caWordList.GetAt(i).m_strWord+"</word><scores>"+
m_caWordList.GetAt(i).m_strScores+"</scores></word_data>";
}
-Steven Hicks
CPACodeProjectAddict
|
|
|
|