I am working towards the BFS algo.
My algo works completely fine with 2D array (without using pointers) but not with 3D (with pointers like ***array) .....
can some1 help why?
I am working towards the BFS algo.
My algo works completely fine with 2D array (without using pointers) but not with 3D (with pointers like ***array) .....
can some1 help why?
this is my code:
n I am getting a Bus error!Code:bfs(int ***array2, int *visited, int start){ int q[nodes],rear=-1,front=-1,i,j; q[++rear]=start; visited[start]=1; while(rear != front) { start = q[++front]; printf("%c \t",start+49); for (i=0; i<iter; i++){ for (j=0; j<nodes; j++){ if(array2[i][start][j] && !visited[j]) { q[++rear]=i; visited[j]=1; }}}} }
It's hard to imagine how much worse you could make your code formatting.
Seriously, random indentation and multiple braces on a line is NOT the way to go.
Also, you need to show us what exactly "a 3D array" looks like when you call this function.
Simply saying
int foo[2][2][2];
then passing it to a function expecting int*** just isn't going to work.
Replacing [] with * only works for ONE level, it is not applied recursively.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
my 3 D array is an adjacency matrix but multiple times.
I mean i have 4 different matrices of 6x 6 dimensions.
My dinner has several vegetables colours red, green and orange - what are they?
HOW the hell are we supposed to debug from that pithy comment?
SHOW us what it is, don't just describe it in vague "it's an adjacency matrix".
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thanks!
No problem - glad you sorted it out!
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.