How to check if all the values of an array are equal to 0?

后端 未结 5 1455
感情败类
感情败类 2021-01-16 14:02

The context of the program is a game involving pegs and discs. The user inputs the amount of pegs (max of 20) and the amount of discs on each peg (max of 10). Two players go

5条回答
  •  粉色の甜心
    2021-01-16 14:21

    try memcmp instead of having separate function with for loop:

    int zeros[sizeof(yourArray)];
    if(memcmp(yourArray,zeros,sizeof(yourArray))==0)
    //do things
    else
    //do things
    

提交回复
热议问题