dllbridge

Untitled

Apr 5th, 2026
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include   <stdio.h>
  5. #include  <string.h>
  6.  
  7.  
  8. /////////////////////////////////////////
  9. struct T
  10. {
  11.    
  12.     int nLen;        //  Длина строки
  13.    
  14.     int nInt;
  15.     int nFloat;
  16.    
  17.     T()
  18.     {
  19.        
  20.         nLen   = 0;
  21.         nInt   = 0;
  22.         nFloat = 0;
  23.     }
  24.    
  25.     void check_int  (char *p);
  26.     void check_float(char *p);
  27.    
  28. };
  29.  
  30. ///////////////////////////////////////////////
  31. int main()
  32. {
  33.    
  34.     char sz[99] = "123,";
  35.    
  36.     T t_1;
  37.    
  38.    
  39.    
  40.     t_1.check_int(sz);
  41.            
  42.     if(t_1.nInt == 1)
  43.     {              
  44.        printf("integer\n");
  45.        goto L_01;  
  46.     }
  47.    
  48.     t_1.check_float(sz);
  49.     if(t_1.nFloat  == 1)
  50.     {              
  51.        printf("it is float\n");
  52.        goto L_01;  
  53.     }  
  54.    
  55.     printf("it is C-string\n");
  56.    
  57. L_01: return 0;
  58.  
  59. }
  60.  
  61.  
  62. ////////////////////////////////////////////////
  63. void T::check_int(char *p)
  64. {
  65.     nLen = strlen(p);
  66.    
  67.     int nF = 1;
  68.    
  69.     for(int i = 0; i < nLen; i++)
  70.     {
  71.        
  72.         if(p[i] < 48 || p[i] > 57) nF = 0;
  73.        
  74.     }
  75.    
  76.     if(nF == 1) nInt = 1;
  77. }
  78.  
  79.  
  80.  
  81. ////////////////////////////////////////////////
  82. void T::check_float(char *p)
  83. {
  84.    
  85.     int nPoint = 0;
  86.    
  87.     for(int i = 0; i < nLen; i++)
  88.     {
  89.         if(p[i] == 44)  nPoint ++;
  90.     }  
  91.      
  92.      
  93.     if(nPoint == 1) nFloat = 1;
  94.     else                return;
  95.    
  96.     int nF = 1;
  97.    
  98.     for(int i = 0; i < nLen; i++)
  99.     {
  100.        
  101.         if((p[i] < 48 || p[i] > 57)  && p[i] != 44) nF = 0;
  102.        
  103.     }
  104.    
  105.     if(nF != 1)  nFloat = 0;   
  106.    
  107. }
  108.  
  109.  
Advertisement
Add Comment
Please, Sign In to add comment