fork download
  1. #include <iostream>
  2. #include <string>
  3. #include "font.h"
  4. using namespace std;
  5.  
  6. // NOTE: www.cprogramming.com/tutorial/bitwise_operators.html
  7.  
  8. void display_char(int);
  9. int find_char(unsigned char(*)[5]); // trouble declaring function prototype
  10.  
  11. int main()
  12. {
  13. // PART 1:
  14. for(int j = 0 ; j < 96; j++)
  15. {
  16. display_char(j);
  17. cout << endl;
  18. cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
  19. cout << endl;
  20. }
  21.  
  22. // PART 2:
  23. int char_index = find_char(font_5x7[96][5]);
  24. cout << "The index of our character for the outer dimension of font_5x7[95][5] is " << char_index << endl;
  25.  
  26. return 0;
  27. }
  28.  
  29.  
  30. void display_char(int index) // index = {0 ... 95} for 96 ASCII chars
  31. {
  32. for(int i = 7 ; i > 0; i--) // 7 iter. {7 ... 1}
  33. {
  34. for(int j = 0 ; j < 5; j++) // 5 iter. {0 ... 4} , TOT. ITER: 35
  35. {
  36. // j keeps track of a collumns of bits making up one byte; 5 collums of bytes = 1 bitmap for an ASCII char
  37. unsigned char target = font_5x7[index][j];
  38.  
  39. // '<<' left shift operator
  40. if((target & (1 << i)) == 0) cout << "At letter index: " << index << ',' << " column: " << j << ", there is a 0" << endl;
  41. else cout << "At letter index: " << index << ',' << " column: " << j << ", there is a 1" << endl;
  42. }
  43. cout << endl;
  44. }
  45. }
  46.  
  47.  
  48. // INPUT: two-dimensional unsigned char array font_5x7[95][5] from font.h
  49. // OUTPUT: integer type representing the index of the bitmapped character in font_5x7 else -1
  50. int find_char(unsigned char font_5x7[][5])
  51. {
  52. unsigned char lookfor[5] = {0xfe,0x92,0x92,0x92,0x82};
  53.  
  54. for(int i = 0; i < 95; ++i)
  55. {
  56. int check = 0;
  57.  
  58. for(int j = 0; j < 5; ++j)
  59. {
  60. if(lookfor[j] == font_5x7[i][j])
  61. {
  62. ++check;
  63. if(check == 5) return i;
  64. continue;
  65. }
  66. else break;
  67. }
  68. }
  69.  
  70. return -1;
  71. }
  72.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:18: fatal error: font.h: No such file or directory
compilation terminated.
stdout

Standard output is empty