Just a couple small c programs.

myecho.c 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. Copyright (c) 2013, Lily Carpenter
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without modification,
  5. are permitted provided that the following conditions are met:
  6. Redistributions of source code must retain the above copyright notice, this
  7. list of conditions and the following disclaimer.
  8. Redistributions in binary form must reproduce the above copyright notice, this
  9. list of conditions and the following disclaimer in the documentation and/or
  10. other materials provided with the distribution.
  11. Neither the name of Lily Carpenter nor the names of its
  12. contributors may be used to endorse or promote products derived from
  13. this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  18. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  21. ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <fcntl.h>
  28. const int size = 50; // chose this number for no particular reason
  29. int main() {
  30. unsigned int number = 0;
  31. unsigned int array[size];
  32. int total;
  33. while ((total = fread(array, sizeof number, size, stdin))){
  34. for (int i = 0; i < total; i++){
  35. printf("%u\n", array[i]);
  36. }
  37. }
  38. }