Guest User

Untitled

a guest
Jan 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "blank.h"
  3. #include "boolean.h"
  4.  
  5. int main()
  6. {
  7. bool result = blank("");
  8.  
  9. printf("%dn", result);
  10.  
  11. return 0;
  12. }
  13.  
  14. // Header file for blank function
  15.  
  16. bool blank(char string[]);
  17.  
  18. #include "boolean.h"
  19. #include "blank.h"
  20. #include <regex.h>
  21.  
  22. bool blank(char string[])
  23. {
  24.  
  25. regex_t regex_blank;
  26. int blank = regcomp(&regex_blank, "[:blank:]", 0);
  27.  
  28. blank = regexec(&regex_blank, string, 0, NULL, 0);
  29.  
  30. if ( string == NULL || blank == 1 )
  31. return true;
  32. else
  33. return false;
  34. }
  35.  
  36. // Boolean
  37.  
  38. // Define true
  39. #ifndef true
  40. #define true 1
  41. #endif
  42.  
  43. // Define false
  44. #ifndef false
  45. #define false 0
  46. #endif
  47.  
  48. typedef int bool;
  49.  
  50. gcc Test.c blank.c -o b
  51.  
  52. In file included from Test.c:2:0:
  53. blank.h:3:1: error: unknown type name ‘bool’
  54. blank.c: In function ‘blank’:
  55. blank.c:11:46: error: ‘NULL’ undeclared (first use in this function)
  56. blank.c:11:46: note: each undeclared identifier is reported only once for each function it appears in
  57.  
  58. gcc Test.c blank.c -o b
  59.  
  60. gcc *.c
  61.  
  62. #ifndef BLANK_H_INCLUDED
  63. #define BLANK_H_INCLUDED
  64.  
  65. bool blank(char string[]);
  66.  
  67. #endif
  68.  
  69. // Header file for blank function
  70.  
  71. #include "boolean.h"
  72. bool blank(char string[]);
  73.  
  74. #ifndef BLANK_H
  75. #define BLANK_H 1
  76. // Header file for blank function
  77.  
  78. bool blank(char string[]);
  79. #endif
Add Comment
Please, Sign In to add comment