Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to judge the length of integer array by C language
How to judge the length of integer array by C language
No, strlen(num) must get 100, because the definition statement int num[ 100] means that space with the length of 100 has been allocated in memory, and strlen only gets the length of allocated space in memory, so it is definitely not acceptable.

I think when you define int num( 100), you can initialize the whole array to a fixed value (preferably a value that can't fit behind), such as 0 or the constant INT_MAX in C. In this case, when you save a certain number of numbers in the array, use a loop statement to search the array from beginning to end. When you encounter a value that is not specified by you,

int count = 0;

for(I = 0; I< 100; i++)

{

if(num[i]! = specified value)

{

count++;

}

other

{

Break;

}

}

Cout & lt& lt "deposited"