Skip to content

Commit

Permalink
Changes in array_insert and array_print
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhant3s committed Aug 18, 2010
1 parent 4b1fe8d commit 7f03803
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions q1.c
Expand Up @@ -6,7 +6,7 @@
*/
#include <stdio.h>

int array_print(int *a, size_t size)
void array_print(int *a, size_t size)
{
while(size--)
printf("%i ",*a++);
Expand All @@ -29,16 +29,17 @@ with the error printed on stderr*/
int *p=a+position;//the pointer to the location where the new element will get inserted
a=a+size;//a points to one past the last element of original array
while(a!=p)
*a--=*(a-1);
*(a--)=*(a-1);
*a=element;
return 1;
}
main()
int main()
{
int a[10]={5,4,1,2,5};
size_t s=(sizeof a)/(sizeof *a);
//printf("Size:%i",s);
array_print(a,s);
array_insert(a,5,121,5);
array_print(a,s);
return 0;
}

0 comments on commit 7f03803

Please sign in to comment.