Advertisement
glokyfull

question static int newbie en c je suis

Jun 26th, 2023
1,545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. static int n=0;  // question : how could i do a static int in the main fonction cause this silly n has not to be general over 1 milion line of code
  6.  
  7.  
  8. void messagetextinit()
  9. {
  10.     printf(";\n")
  11.     printf(";\tThis code is generated\n");
  12.     printf(";\t and can be overwriten\n");
  13.     printf(";\t\if you want to edit, work on a copy on another folder\n");  
  14.     printf("\n);
  15. }  
  16. void writedcb(short int x)
  17. {
  18.     if (n==0)
  19.     {
  20.       printf("dc.w %d,",x);
  21.     }
  22.     else if (n==15)
  23.     {
  24.      printf("%d\n",x);
  25.     }
  26.     else
  27.     {
  28.      printf("%d,",x);
  29.     }
  30.     n=(n+1) & 15;
  31. }
  32. void nl()
  33. {
  34.     printf("\n");
  35. }
  36.  
  37.  
  38. int ajoutemask(int* tab,int masque,int champvaleur)
  39. {
  40.     for (int i=0;i<65536;i++)
  41.     {
  42.         int v=i & masque;
  43.         tab[v]=champvaleur;
  44.     }
  45.    
  46.    
  47. }
  48.  
  49. int main(int argc,char** argv)
  50. {
  51.     messagetextinit;
  52.     int sinx;
  53.     for(int i=0;i<1540;i++)
  54.     {
  55.         int value=32767*sin((i+0.5)*2*3.1415926/1540/4);
  56.         if (i<(1540-1))
  57.         {
  58.             writedcb(value);   
  59.         } else
  60.         {
  61.            printf("%d\n",value);
  62.         }
  63.     }
  64.     nl;
  65.    
  66.    
  67.     int* tableauflag = malloc(sizeof(int)*65536);
  68.    
  69.    
  70.    
  71.    
  72.    
  73.    
  74.    
  75.    
  76.    
  77.    
  78.    
  79.    
  80.    
  81.    
  82.    
  83.    
  84.  
  85. }
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement