![]() |
unexpected output
please xplain the output of following program....
Code:
#include<iostream.h>kaushal swapnil kaushal swapnilkaushal shal 8 |
Re: unexpected output
You have undefined behaviour, because b is not long enough for "swapnil"+"kaushal" - total 15 characters, but b is only 10 chars long.
So anything could happen, and the solution to the problem is to extend b to at least 15 characters so that it can cope with what you want to do. Or use strings so you can do b+=c without worrying about buffer sizes. This is a buffer overflow bug. |
| All times are GMT +5.5. The time now is 12:27. |