Read value from adress with pointers

0 Aybars Arslan · March 4, 2015
Hello, I need to some help.

i want to write some numbers till write 0, when i wrote 0 the program must be stop and show the numbers in order, anybody can help me ? 

its almost finish but i have one problem.
it my code  :

i mustn't use array, its forbidden :) 

Post a Reply


Oldest  Newest  Rating
0 c student · March 4, 2015
you can use a linked list and place the numbers into their respective positions as you enter them in.
0 Aybars Arslan · March 5, 2015
its forbidden to use lists

but i solve the problem its answer


int main()
   int* number;
   int i = 0, j = 0;

   number = (int*)malloc(2000);

       printf("Enter a number : ");

/*   TEST
       printf("%d. number = %d \t%p\n",i+1,*(number+i),number+i);
   }while(*(number+i-1) != 0);

   for(j = 0 ; j < i; j++){
//TEST      printf("%d. number = %d \t%p\n",j+1,*(number+j),number+j);
       printf("%d. number = %d\n",j+1,*(number+j));

   return 0;
0 Dol Lod · March 5, 2015
I thought you said you weren't allowed arrays, but number is a dynamically allocated array. An alternative is a queue to show everything in order unless you mean that you can't use collections at all. 
0 Clark Alaan · April 12, 2015
Well, an alternative would also be using encryption using shift operators. Unfortunately I haven't played around with them too much so I don't know how to teach you. :(
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator