Click here to Skip to main content
15,789,360 members

Comments by Shobhit_23 (Top 4 by date)

Shobhit_23 21-Oct-23 13:28pm View    
Thanks for the suggestion, I will definitely use it.
Shobhit_23 16-Oct-23 9:45am View    
Okay, a slightly different doubt now, to verify this I have now kept a count variable(in register ebx), I am incrementing it on each increment-ation of eax. I am now comparing it against 142, so that the value of ebx doesn't get to it's maximum. I was expecting to see a large value(around 2^16) in ebx, but what I am seeing is -2. Can you explain it?

#include <stdio.h>

int main() {
	int x = 144;
	int y;
	__asm {
		mov eax, x
		mov ebx, 0
red:	inc eax
		inc ebx
		cmp eax, 142
		jnz red
		mov x, eax
		mov y, ebx
	};
	printf("%d\n", x);
	printf("%d\n", y);
	return 0;
}
Shobhit_23 7-Jan-23 8:01am View    
Thanks for the help I get it now, although it feels a little intimidating to use pointer to pointer. On a side note I am already updating the head_ptr on first insertion.

head_ptr = (struct Node*)malloc(sizeof(struct Node));
Shobhit_23 7-Jan-23 7:57am View    
Thanks for the help, the linkedlist is working as expected now, but I have two queries.
1) Isn't it better to use else if, as it makes the logic more explicit? Is there any performance difference of one over the other?
2) How is "new" superior to malloc(), although I am using C not C++ so can't use new here, but still why is new preferred over malloc() when it is available?