Thread: Wth is wrong with this code?

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    71

    Wth is wrong with this code?

    Code:
    void radixsort(unsigned long (*array)[],int size){
      int u;
      printf("sizeof the array = %i\n",size);
      unsigned long *views;
      views = *array;
      for(u=0;u<size;u++){
        printf("%i,",(*array)[u]);
        printf("%i,",(*views)++);
      }
    }
    This is the output 3,3,4,4,2,5,1,6,6,7,4,8,8,9, and the array is [3,4,2,1,6,4,8]
    What's going on?!

  2. #2
    Registered User
    Join Date
    Oct 2012
    Posts
    71
    I also checked the memory addresses with
    Code:
      for(u=0;u<size;u++){
        printf("%i and",&((*array)[u]));
        printf("%i,",&((*views)));views++;
      }
    and both addresses were the same.

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    71
    Ops figured out that the ++ is supposed to be inside the paranthesis. *facepalm*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's wrong with this code?
    By Chrys in forum C Programming
    Replies: 4
    Last Post: 03-12-2012, 07:10 AM
  2. what is wrong with this code
    By gammanu882 in forum C++ Programming
    Replies: 7
    Last Post: 01-05-2011, 05:53 AM
  3. What's wrong with the code?
    By meili100 in forum C++ Programming
    Replies: 3
    Last Post: 04-09-2008, 04:11 AM
  4. HELP! What's wrong with my code!
    By fp123 in forum C++ Programming
    Replies: 5
    Last Post: 01-20-2006, 12:05 PM
  5. What's wrong with this code?
    By stillwell in forum C++ Programming
    Replies: 23
    Last Post: 10-03-2004, 03:04 PM