[Solved] unable out figure out error in below program [closed]


This is a case of undefined behavior: if(!visited[j]) is undefined. visited is not initialized because the call memset(visited, sizeof(visited), false); is wrong. You are reading uninitialized variables.

The declaration of memset is

void *memset( void *dest, int ch, size_t count );

You are writting 0 times the value 10000 into visited. On your machine this memory was filled with zeros. But on other machines there can be different values.

6

solved unable out figure out error in below program [closed]