Why atof causes a C0000005 exeption?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2007
Posts: 47
Reputation: Arctic wolf is an unknown quantity at this point 
Solved Threads: 1
Arctic wolf Arctic wolf is offline Offline
Light Poster

Re: Why atof causes a C0000005 exeption?

 
0
  #11
Aug 20th, 2007
vijayan121 thank you for the links.
Salem,my program looked like this after the edits:
  1.  
  2. #include<stdio.h>
  3. #include<conio.h>
  4. #include<stdlib.h>
  5. #include<sstream>
  6. #include<iostream>
  7.  
  8.  
  9. using namespace std;
  10.  
  11. void main ()
  12. {
  13. double num;
  14.  
  15. num=310.589;
  16. char buffer [15];
  17.  
  18. sprintf(buffer,"%f",num);
  19.  
  20. printf("\nbuffer=\n");
  21. printf(buffer);
  22. printf("\npartial buffer=\n");
  23. printf((char *)&buffer[3]);
  24. printf("\nEnter a number:\n");
  25. //cin>>buffer;
  26. scanf("%s",buffer);
  27. //num=atof(buffer);
  28. stringstream(buffer)>>num;
  29.  
  30. printf("\n%f",num);
  31.  
  32. _getch();
  33.  
  34.  
  35.  
  36. }

it compiled end builded with no problems,but when executing the program ignores the line:
  1. stringstream(buffer)>>num;
and the initial value of num doesn't change(remains 310.589).
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: Why atof causes a C0000005 exeption?

 
0
  #12
Aug 20th, 2007
works fine on my machine; after kicking out <conio.h> and changing void main() to int main().
which compiler are you using? try stringstream stm(buffer) ; stm >> num;
Last edited by vijayan121; Aug 20th, 2007 at 3:43 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Why atof causes a C0000005 exeption?

 
1
  #13
Aug 20th, 2007
> printf(buffer);
Never use a string you're not in complete control of as the format string for printf.
If anyone ever got a % character into that, your code would be seriously broken.
http://en.wikipedia.org/wiki/Format_string_attack

It's best to always use string constants for printf/scanf formats.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 47
Reputation: Arctic wolf is an unknown quantity at this point 
Solved Threads: 1
Arctic wolf Arctic wolf is offline Offline
Light Poster

Re: Why atof causes a C0000005 exeption?

 
0
  #14
Aug 27th, 2007
Salem,thank you for the link,I will take this information in mind from now on.

vijayan121, I use VC++ 6.0,
I tried the edits you suggested,it started to give the error message again(actualy even when I removed only the:
  1. _getch()
,the compiler gave an error message,weird isn't it).
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Why atof causes a C0000005 exeption?

 
0
  #15
Aug 27th, 2007
Another case of people reading advice but not really acting on it.

The very first thing you need to do is get rid of vc++ 6.0 and either get VC 2005 express or something like dev-cpp.

And then you can ignore all these little conclusions you are drawing, which quite frankly is going to be nonsense because of the tool you're using.
Last edited by iamthwee; Aug 27th, 2007 at 9:38 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 47
Reputation: Arctic wolf is an unknown quantity at this point 
Solved Threads: 1
Arctic wolf Arctic wolf is offline Offline
Light Poster

Re: Why atof causes a C0000005 exeption?

 
0
  #16
Aug 27th, 2007
I thought maybe it will help if I quote the entire error message:
LINK : error : Internal error during ReadSymbolTable
ExceptionCode = C0000005
ExceptionFlags = 00000000
ExceptionAddress = 00465817
NumberParameters = 00000002
ExceptionInformation[ 0] = 00000000
ExceptionInformation[ 1] = 00F91184
CONTEXT:
Eax = 00F91180 Esp = 0012F61C
Ebx = 00000000 Ebp = 004A2678
Ecx = 00F91180 Esi = 00F60E94
Edx = 00000001 Edi = 004A2928
Eip = 00465817 EFlags = 00010212
SegCs = 0000001B SegDs = 00000023
SegSs = 00000023 SegEs = 00000023
SegFs = 0000003B SegGs = 00000000
Dr0 = 0012F61C Dr3 = 00000000
Dr1 = 004A2678 Dr6 = 00F91180
Dr2 = 00000000 Dr7 = 00000000
Error executing link.exe.
Tool execution canceled by user.
so, the "Exception code:" is ofcourse the number of the exception.

"Exception address" is the address in memory where the exception occured(please correct me if I'm wrong).

Eax,Ebx,Ecx,Edx- are the registers if I understand correctly(what their
contents means in this case I don't know).

Besides those stuff, I don't understand anything from the above error information,so I don't realy see the entire picture of the error.

Maybe someone can point me the right direction in analyzing this information?
Last edited by Arctic wolf; Aug 27th, 2007 at 9:57 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Why atof causes a C0000005 exeption?

 
0
  #17
Aug 27th, 2007
>Maybe someone can point me the right direction in analyzing this information?

Step one, please re-read the following...

http://www.daniweb.com/forums/post425170-15.html
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 47
Reputation: Arctic wolf is an unknown quantity at this point 
Solved Threads: 1
Arctic wolf Arctic wolf is offline Offline
Light Poster

Re: Why atof causes a C0000005 exeption?

 
0
  #18
Aug 27th, 2007
iamthwee,
heard your advice before,tried the vc++ 2005 express,the problem is that it doesn't have the ability to work with resource files.
And I'm not sure whether my problem occures because of the compiler or because of the program itself.
Last edited by Arctic wolf; Aug 27th, 2007 at 9:55 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Why atof causes a C0000005 exeption?

 
0
  #19
Aug 27th, 2007
Really, have you installed the windows sdk which you have to download separately for vc 2005 express?

Or have you tried dev-cpp which already has support for resource files and is less than a 10MB download?
Last edited by iamthwee; Aug 27th, 2007 at 10:00 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 47
Reputation: Arctic wolf is an unknown quantity at this point 
Solved Threads: 1
Arctic wolf Arctic wolf is offline Offline
Light Poster

Re: Why atof causes a C0000005 exeption?

 
0
  #20
Aug 27th, 2007
Really, have you installed the windows sdk which you have to download separately for vc 2005 express?

Or have you tried dev-cpp which already has support for resource files and is less than a 10MB download?
I will do that.

But I still would like to learn to analyze the error data I mentioned above.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC