I'm trying to caculate the execution time of program given below but it is giving me some errors
#include<stdio.h>
#include<time.h>
int main()
{
clock_t start, end;
start = clock();
int a[5] ={1,2,3,4,51};
int b[5] = {2,3,4,5,6};
int c[5] = {3,4,5,6,7};
for (int i =0;i<5;i++)
{
if(a[i]== NULL )
printf("%d element null::",a[i]);
else
printf("no null values in first array\n");
if(b[i]== NULL )
printf("%d element null::",b[i]);
else
printf("no null values in second array\n");
if(c[i]== NULL )
printf("%d element null::",c[i]);
else
printf("no null values in third array\n");
}
end = clock();
printf("Start time: %i, End time: %i \n" start, end);
return 0;
}
following are the errors and warnings..
[eshwar@localhost ~]$ gcc -std=c99 ab.c
ab.c: In function ‘main’:
ab.c:18:9: warning: comparison between pointer and integer [enabled by default]
if(a[i]== NULL )
^
ab.c:24:16: warning: comparison between pointer and integer [enabled by default]
if(b[i]== NULL )
^
ab.c:30:16: warning: comparison between pointer and integer [enabled by default]
if(c[i]== NULL )
^
ab.c:39:44: error: expected ‘)’ before ‘start’
printf("Start time: %i, End time: %i \n" start, end);
and why is this warning given..because I think we can initialise array like this??
Aucun commentaire:
Enregistrer un commentaire