Well yes that makes sense ... but if by memory corruption means that some parts of allocated structures overlap and a garbage value is being printed, why is it always 0? and why is getch() not...
Type: Posts; User: Sumone Unknon
Well yes that makes sense ... but if by memory corruption means that some parts of allocated structures overlap and a garbage value is being printed, why is it always 0? and why is getch() not...
I changed the title from "Russian Roulette" to "Josephus problem"
Thanks for telling me the real name of the problem :)
Do you mean like this?
new1 = (struct node*) malloc( ( ( sizeof(struct node*) )*2 ) + 2);
Isn't a pointer always of size 2 bytes?
I used sizeof(struct node*) and got 2 bytes. Integer was also 2 bytes.
So 2+2+2 = 6 bytes.
EDIT:
Also, in line 72, it must be malloc(6), changing 4...
Hi
I am writing a program of Josephus problem in which each player kills next player and the person which is left is winner.
For Example, for 5 players
1 -- 2 -- 3 -- 4 -- 5
Starting with 1,...
Hi
When running following code, it gives correct output but a warning something like: "Incorrect Pointer Conversion"
void main()
{
int a[2][2] = {{1,2}, {3,4}}, *b = &a;