|
yes, When I change the config of my program, so, it have to write in the config.pcm. All the configurations of my program are written on config.pcm except for the hotkeys ( the bolded code )
|
|
|
|
|
How can you see the file pointer advancing? How many HOTKEY items did you successfully write (i.e. Did you check temp value? Did you check fwrite return value?)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
when debuging, just watch for the file pointer, so, I can see fout increase the value, I write 1 or 2 HOTKEY to try, but the content no change. When I read the file, the value is 0 >.<
|
|
|
|
|
Cadimi wrote: I write 1 or 2 HOTKEY to try
But then do you close the file?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
as you can see in the code, I closed it, and before closed it, I fflush( fout ) carefully
|
|
|
|
|
Yes, I saw the code, anyway I was referring to you debugging actions (i.e. I didn't know if you stopped the program after few write operations).
The reason behind my questions is I cannot believe fwrite silently failing, it never happened to me.
Can't you isolate the failing piece of the writing routine and run it in a simpler context (for instance another, adhoc, project)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
thanks for your help, that's the worse thing I've ever met >.<
|
|
|
|
|
Cadimi wrote: FILE *fout = fopen( "config.pcm", "wb" );
Are you using a relative path?
What is the value of temp ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
temp is the number of hotkeys, its value is the size of the vector contain my HOTKEY struct
|
|
|
|
|
Cadimi wrote: temp is the number of hotkeys, its value is the size of the vector contain my HOTKEY struct
I know what it represents. I asked what its value was (at the time of writing to the file).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I tried a simple example, its value at that time is 1
|
|
|
|
|
Ok, what do the two subsequent calls to fwrite() return?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I just watch the file pointer, it increase the value equal to the size I've requested to write on file
|
|
|
|
|
But what do the two subsequent calls to fwrite() return?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I've found my problem ... It happened when I ust CFileDialog in another code, select a path, then the default directory change too => write file at another place => can't read. Thanks for your help
|
|
|
|
|
Cadimi wrote: ...can't read.
Which is why I was asking if fopen() was failing.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
struct nids_prm
{
...
void (*syslog) ();
...
};
static void my_nids_syslog(int type, int errnum, struct ip_header *iph, void *data)
{}
main()
{
nids_params.syslog = my_nids_syslog;
...
}
error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)'
how to solve it?
|
|
|
|
|
CHYGO wrote: error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)'
i think i cannot explain more clear than that.
function parameters are not same.
CHYGO wrote: how to solve it?
it depends on your need, may be,
struct nids_prm
{
...
void (*syslog) (int,int,struct ip_header *,void *);
...
}; matches your need.
BTW, a basic C programing book can also solve.
|
|
|
|
|
thx, i need another mothes
i'll try it
|
|
|
|
|
Short answer: this way
struct nids_prm
{
...
void (*syslog) (int , int , struct ip_header *, void *);
...
};
Long answer: use variable number of argument for your functions (and modify accordigly syslog declaration).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
thank u
|
|
|
|
|
In nids_prm struct, replace void (*syslog) (); with this: void ( *syslog ) ( int , int , struct ip_header * , void * );
When you declare a function pointer, you have to define exactly the parameters of that function ^^. Enjoy yourself ^^
|
|
|
|
|
i've tried ,and the error is the same
|
|
|
|
|
CHYGO wrote: cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)'
that's pretty clear, no ?
you're passing parameters to a function which requires none !
|
|
|
|
|
i don't know what's the problem is -_-!
when i drag the .c file into the VC6, the build the default project,then compile ,nothing happen
but when i build a WIN32 or MFC application , the error occur...
|
|
|
|