|
Cedric Moonen wrote: this is the 59567 time (approximately)
You had several integer overflows, it seems.
I must have been many more than MAX_INT times...
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
jhwurmbach wrote: You had several integer overflows, it seems.
Yeah, I knew I should have used an unsigned __int64
|
|
|
|
|
Cedric Moonen wrote: this is the 59567 time (approximately) that this question has been asked
And exactly?
|
|
|
|
|
Hamid. wrote: And exactly?
60000
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Use the atoi function:
like
<br />
char s[]="1234";<br />
int x= atoi(s);<br />
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
Depends on how long the string is, and as a consequence, how large the number will be.
Look at the documentation for atoi, atol, atoll, etc.
[EDIT: oops! too slow]
The easiest way to make the world a better place is to refuse to help those that wreck it....
|
|
|
|
|
A example in MSDN
--------------------------------
Example
/* ATOF.C: This program shows how numbers stored
* as strings can be converted to numeric values
* using the atof, atoi, and atol functions.
*/
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
char *s; double x; int i; long l;
s = " -2309.12E-15"; /* Test of atof */
x = atof( s );
printf( "atof test: ASCII string: %s\tfloat: %e\n", s, x );
s = "7.8912654773d210"; /* Test of atof */
x = atof( s );
printf( "atof test: ASCII string: %s\tfloat: %e\n", s, x );
s = " -9885 pigs"; /* Test of atoi */
i = atoi( s );
printf( "atoi test: ASCII string: %s\t\tinteger: %d\n", s, i );
s = "98854 dollars"; /* Test of atol */
l = atol( s );
printf( "atol test: ASCII string: %s\t\tlong: %ld\n", s, l );
}
Output
atof test: ASCII string: -2309.12E-15 float: -2.309120e-012
atof test: ASCII string: 7.8912654773d210 float: 7.891265e+210
atoi test: ASCII string: -9885 pigs integer: -9885
atol test: ASCII string: 98854 dollars long: 98854
|
|
|
|
|
yogesh_softworld123 wrote: char s[]="1234";
to integer like 1234
_ttoi
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
when I loading the dll and callling its function then I get the
following error how can I solve it.
DebugError
-----------
Program :\Project\Test.exe
Module:
File:i386\chkespc.c
Line:42
The value of ESP was not properly saved across a function call.This is usually a result
of calling a function declared with no calling convention with a function pointer declared
with a different calling convention.
Trioum
|
|
|
|
|
From where are you calling the function ? Something like VB ?
You need to change the calling convention to __stdcall.
Put some code if you want more information.
|
|
|
|
|
Check the calling convention of function.
|
|
|
|
|
trioum wrote: This is usually a result
of calling a function declared with no calling convention with a function pointer declared
with a different calling convention
Isn't it clear? Your (calling) code probably use a calling convention that doesn't match the one DLL function expects.
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
|
|
|
|
|
I am using the MSvc++ to call the dll
I call the function as follows
I defined the function in dll as follows
extern "C" __declspec(dllexport) int Adddata(void* item);
DllMain()
{
}
int Adddata(void* item)
{
//some processingen here
}
in my test.exe i called as follows
struct _data
{
// some fields;
}
onButtonclick()
{
struct _data *data = (struct _data*)malloc(sizeof(struct _data ));
//some inityialization code here
data->someintvalue;
strcpy(data->somecharvlaue,"hfd");
//
int rvalue = Adddata(data); // dll function called
--here the debug error come---------
}
Trioum
|
|
|
|
|
Uhm... Seems a dynamic memory handling issue. Could you please post the code details (i.e. the actual struct definition, its initialization, the Adddata function implementation)?
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
|
|
|
|
|
due to code security issue I cannot send the details of the Adddata function in open forum.
I am sure no error in that function and returning well the rvalue .
Trioum
|
|
|
|
|
Well, good luck.
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
|
|
|
|
|
good luck but why I am still facing the same problem
Trioum
|
|
|
|
|
No code, no help: Sorry I have my CPMRU (C ode P roject M ind R eader U nit) out of order today.
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
|
|
|
|
|
trioum wrote: I defined the function in dll as follows
How is it declared in your exe ? Because that's just the part in the dll. Is it in the same file with precompiled directives (#ifdef...)
How do you load the dll ? Is it using LoadLibrary/GetProcAddress or linking to a static library ?
You need to provide more information if you want a solution.
|
|
|
|
|
I am linking to a static library and I defined it in exe as follows
extern "C" __declspec(dllexport) int Adddata(void* item);
Trioum
|
|
|
|
|
trioum wrote: extern "C" __declspec(dllexport) int Adddata(void* item);
No, that's in the dll: you have dllexport, you should have a dllimport for the exe. Where is this line of code ? In which file ? Show the code of this header file.
Did you make a search on google about calling conventions ?
Sorry, but if you are so sparse about giving informations, there's no way for us to help you.
|
|
|
|
|
sorry sir I typed wrong due to hurry it is dllimport i.e.
extern "C" __declspec(dllimport) int Adddata(void* item);
Trioum
|
|
|
|
|
now I tested another function that is working fine but not previous one
the new function as follows
defined in dll as
extern "C" __declspec(dllexport) int testfunction();
dllmain()
{
}
int testfunction()
{
return 2;
}
in my .exe it is as follows
extern "C" __declspec(dllimport) int testfunction();
onButtonclick()
{
int rvalue = testfunction();
//above code return rvalue is 2 and no error
}
Adddata(void* item); still firing same debug error
Trioum
|
|
|
|
|
That's normal: you don't pass any arguments to the function, so there's no cleaning of the stack for the arguments. So, calling convention has no effect here.
Try something: comment everything that is inside the Adddata function (in your dll). If you don't have the crash, then it probably means that you have a bug in your function.
|
|
|
|
|
trioum wrote: how can I solve it.
At a minimum, you could Google for (parts of) the error message.
"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
|
|
|
|