Advertisement
Mazamin

SimLib

Jun 5th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include "simlib.h"
  5.  
  6. int pulisci(char * vect, int dim){
  7.     if(dim<=0)
  8.         return 0;
  9.    
  10.     for(int i=0;i<dim;++i)
  11.         vect[i]='\0';
  12.    
  13.     return 1;
  14. }
  15.  
  16. int riempi(char * vect, int dim, char c){
  17.     if((dim<=0)||(!isalpha(c)))
  18.         return 0;
  19.    
  20.     int i;
  21.     for(i=0;i<dim-1;++i)
  22.         vect[i]=c;
  23.    
  24.     vect[i]='\0';
  25.    
  26.     return 1;
  27. }
  28.  
  29. int trova(char * vect, int dim, char c){
  30.     if((dim<=0)||(!isalpha(c)))
  31.         return 0;
  32.    
  33.     for(int i=0;i<dim;++i)
  34.         if((vect[i])==c)
  35.             return i+1;
  36.    
  37.     return -1;
  38. }
  39.  
  40. ---------------
  41.  
  42. /*
  43.  * File:   simlib.h
  44.  * Author: Gerardo Cicalese
  45.  *
  46.  * Created on 5 giugno 2019, 13.23
  47.  */
  48.  
  49. #ifndef SIMLIB_H
  50. #define SIMLIB_H
  51.  
  52. int pulisci(char *, int);
  53. int riempi(char *, int, char);
  54. int trova(char *, int, char);
  55.  
  56. #endif  /* SIMLIB_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement