sorting - Displaying content of an array + taking input -


what in world, matter here:

 #include <stdio.h>  int main(int argc, char const *argv[]) {     int array[20];     int *parray = array;     int count;     int = 0;      while(1)         {             scanf("%d", array+i );             if(*(parray+i) == -1) break;             i++;         }      printf("contents: ");      while(1){           if (*(parray + i) != -1)            {            printf("%d ", *(parray + i) );             i++;          }       }      return 0; } 

thank you. trying take input user , display contents of array. going arrange them in order using pointers, i'll wait till replies.

here rewrite attempt:

#include <stdio.h> int main(void) {     int array[20];     int = 0;      while(1)     {         scanf("%d", &array[i] );         if(array[i] == -1) break;         i++;     }      printf("contents: ");      = 0;     // reset counter zero.     while(1)     {         if (array[i] != -1)           {             printf("%d ", array[i] );              i++;         }     }      return 0; } 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -