Click here to Skip to main content
15,890,845 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: When to delete a pointer (C++)... Pin
Joe Woodbury1-Jul-14 6:23
professionalJoe Woodbury1-Jul-14 6:23 
AnswerRe: When to delete a pointer (C++)... Pin
Satya Chamakuri8-Aug-14 23:52
Satya Chamakuri8-Aug-14 23:52 
QuestionMessage Removed Pin
25-Jun-14 22:04
_Flaviu25-Jun-14 22:04 
QuestionBeginner- Floating point character conversion character Pin
BeingGokul24-Jun-14 7:17
BeingGokul24-Jun-14 7:17 
AnswerRe: Beginner- Floating point character conversion character Pin
CPallini24-Jun-14 9:06
mveCPallini24-Jun-14 9:06 
AnswerRe: Beginner- Floating point character conversion character Pin
David Crow24-Jun-14 10:19
David Crow24-Jun-14 10:19 
AnswerRe: Beginner- Floating point character conversion character Pin
M.FarrukhFaizy27-Jun-14 8:45
M.FarrukhFaizy27-Jun-14 8:45 
AnswerRe: Beginner- Floating point character conversion character Pin
Satya Chamakuri9-Aug-14 1:46
Satya Chamakuri9-Aug-14 1:46 
Hi Gokul,

I understood your doubt. Here i am trying to clarify why it is happening clearly.

printf("\n %s %d %f %c", "Gokul", 90,100,'X');

in the above piece of code if you observe clearly, with the assumption of starting address will be 0x1000, the contents of your piece of code will occupy memory as follows.
"Gokul"- at 0x1000
90 - at 0x1006
100 - at 0x1010
'X' - at 0x1015

Now as per your format specifiers first %s will fetch first 6 Bytes("Gokul"),
%d will fetch next 4 bytes of data as integer, so fetches 90,
now %f means it will fetch next 8 Bytes of data means from 0x1010 to 0x1017 which includes memory location of 'X' also, after fetching it will try to display float number but it won't display as no external coversion you are doing. So it will display 0.0000000
Then during this time we are at memory location 0x1018 in which some garbage value(Σ) will be there as we are not storing anything.

Even though if you give some other character in place of 'X' also it will give same value(Σ) as garbage is there in 0x1018 location.

if you change 100 to some float number or explicitly converted to float number((float)100), then it will occupy 8 bytes memory now. then no problems and no unwanted results you get.

If any clarifications feel free to ask, you will get help definitely.

Thank you.

modified 9-Aug-14 7:55am.

QuestionGraphics Pipeline questions Ortho projection Pin
shiftwik23-Jun-14 12:04
shiftwik23-Jun-14 12:04 
QuestionTwo ChlidFrames in MDI application? Pin
Member 1074879523-Jun-14 8:59
Member 1074879523-Jun-14 8:59 
AnswerRe: Two ChlidFrames in MDI application? Pin
shiftwik23-Jun-14 12:08
shiftwik23-Jun-14 12:08 
Questionhow to get rid of this error *** fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory ***** Pin
Member 1089437823-Jun-14 2:08
Member 1089437823-Jun-14 2:08 
AnswerRe: how to get rid of this error *** fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory ***** Pin
leon de boer23-Jun-14 2:16
leon de boer23-Jun-14 2:16 
AnswerRe: how to get rid of this error *** fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory ***** Pin
«_Superman_»23-Jun-14 2:36
professional«_Superman_»23-Jun-14 2:36 
GeneralRe: how to get rid of this error *** fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory ***** Pin
Member 1089437823-Jun-14 2:47
Member 1089437823-Jun-14 2:47 
GeneralRe: how to get rid of this error *** fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory ***** Pin
leon de boer29-Jun-14 17:23
leon de boer29-Jun-14 17:23 
QuestionRe: how to get rid of this error *** fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory ***** Pin
David Crow23-Jun-14 6:01
David Crow23-Jun-14 6:01 
AnswerRe: how to get rid of this error *** fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory ***** Pin
Member 109213042-Jul-14 22:03
Member 109213042-Jul-14 22:03 
QuestionMFC small help please Pin
dan6060622-Jun-14 20:27
dan6060622-Jun-14 20:27 
AnswerRe: MFC small help please Pin
«_Superman_»22-Jun-14 20:48
professional«_Superman_»22-Jun-14 20:48 
GeneralRe: MFC small help please Pin
dan6060622-Jun-14 22:32
dan6060622-Jun-14 22:32 
GeneralRe: MFC small help please Pin
_Flaviu23-Jun-14 22:10
_Flaviu23-Jun-14 22:10 
Questioncan be p[-1] dereferenced? Pin
sakthimuhuu22-Jun-14 18:54
sakthimuhuu22-Jun-14 18:54 
AnswerRe: can be p[-1] dereferenced? Pin
«_Superman_»22-Jun-14 20:22
professional«_Superman_»22-Jun-14 20:22 
AnswerRe: can be p[-1] dereferenced? Pin
Jochen Arndt22-Jun-14 21:00
professionalJochen Arndt22-Jun-14 21:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.