diff --git a/Graph/BFS.cpp b/Graph/BFS.cpp index 798f869f9..cd8d22908 100644 --- a/Graph/BFS.cpp +++ b/Graph/BFS.cpp @@ -30,7 +30,7 @@ void graph::printgraph(){ } void graph::bfs(int s){ bool *visited = new bool[this->v+1]; - memset(visited,false,sizeof(visited)); + memset(visited,false,sizeof(bool)*(this->v+1)); visited[s]=true; list q; q.push_back(s); @@ -57,4 +57,4 @@ int main(){ //g.printgraph(); g.bfs(2); return 0; -} \ No newline at end of file +}