Thread: Altering and recovering an original array.

  1. #1
    Registered User
    Join Date
    May 2017
    Posts
    4

    Altering and recovering an original array.

    I am writing a transformation and attempting to reverse the process. I alter the "data" array, write the array to a file, then I read the file and reverse the transformation. The file is read successfully, I am sure of it. However, the reverse transformation does not yield the original "data" array. The only changing variable besides the array values are the for loop "t" variables.

    Code:
     if (ffit) {
         for(int t=0;t<np;++t) {
    fitvalue[t]= short (data[t]-(28000+(t>=to&&t<=to1)*amp*exp((t-to/tau))));
    ft=&fitvalue[t];
    fwrite (ft,2,1,ffit);  
         }
      }
    
    // Test fit recovery
       if (frecovery) {
          for (int t=0; t<np; ++t) {
    rcv=&recovery[t];
    recovery[t]= (recovery[t]+(28000+(t>=to&&t<=to1)*amp*exp((t-to/tau))));
    fwrite(rcv,2,1,frecovery);
        }
      }   

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 12-07-2011, 06:23 PM
  2. Help altering code to work with char array
    By mikeman in forum C++ Programming
    Replies: 3
    Last Post: 02-16-2010, 07:59 PM
  3. How do I go about recovering these files?
    By JFonseka in forum Tech Board
    Replies: 2
    Last Post: 01-15-2010, 06:43 AM
  4. [C] Sorting an array and preserving the original index
    By frodo_jedi in forum C Programming
    Replies: 10
    Last Post: 04-06-2009, 06:51 AM
  5. Recovering CD-RW Files.
    By civilwarsearch in forum Tech Board
    Replies: 6
    Last Post: 01-08-2004, 08:13 AM

Tags for this Thread