SHARE
TWEET

double array

RicardasSim Mar 20th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-std=c99 -Wall -Wextra -Wpedantic -Wshadow
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <stdint.h>
  6. #include <stdbool.h>
  7.  
  8. #define DARRSIZE 10
  9.  
  10. bool testas(double* arr, uint32_t num)
  11. {
  12.    
  13.     double dV = 0.0;
  14.    
  15.     for(uint32_t i = 0; i < 10; ++i)
  16.     {
  17.         if(num<=i) return false;
  18.            
  19.         *(arr+i) = dV;
  20.         dV += 1.0;
  21.     }
  22.    
  23.    
  24.     return true;
  25. }
  26.  
  27. int main (int argc, char **argv){
  28.  
  29.     double dArr[DARRSIZE]={0.0};
  30.    
  31.     if(!testas(dArr,DARRSIZE))
  32.     {
  33.         printf("error!\n");
  34.         return 1;
  35.     }
  36.    
  37.     for(uint32_t i =0; i < DARRSIZE; ++i)
  38.     {
  39.         //*(dArr+1) dArr[i]
  40.         printf("%f ",dArr[i]);
  41.     }    
  42.    
  43.     printf("\n");
  44.    
  45.     return 0;
  46. }
  47.  
  48. /*
  49. output:
  50.  
  51. 0.000000 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000
  52.  
  53. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top