memset(dist,-1,sizeof(dist))
时间: 2024-05-24 16:11:08 浏览: 162
memset函数的使用分析
This line of code uses the memset() function to initialize an integer array named "dist" with -1 values.
The memset() function is commonly used in C/C++ to set a block of memory to a specific value. It takes three arguments- the memory block to be initialized, the value to be set, and the number of bytes to be set. In this case, the memory block is "dist", the value is -1, and the number of bytes is calculated by multiplying the size of an integer with the size of the array "dist".
Therefore, the effect of this line is to set all elements of the "dist" array to -1, effectively initializing it for use in a graph or distance calculation algorithm.
阅读全文