[ create a new paste ] login | about

Link: http://codepad.org/7wykwpX0    [ raw code | output | fork ]

C, pasted on Nov 4:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>

#define AL 100
#define SL 32

int main(){
	char array[AL][SL] = { "at", "be", "funzey", "zebra" };
	int i,used = 0;
	//i want to find out how much of the array is in use.
	for(i=0;i<AL;i++){
		if(array[i][SL]!=NULL){
			printf("Slot #%i = %s\n",i,array[i]);
			used++;
		}
	}
	printf("Slots used: %i\n",used);
	printf("Slots remaining: %i\n",AL-used);
    return 0;
}


Output:
1
2
3
4
5
Slot #0 = at
Slot #1 = be
Slot #2 = funzey
Slots used: 3
Slots remaining: 97


Create a new paste based on this one


Comments: