Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
877 B

  1. /*
  2. This program ...
  3. */
  4. #include <stdio.h>
  5. #include <string.h>
  6. void Unique()
  7. {
  8. #define BUFFER_SIZE (1024)
  9. char buffer1[BUFFER_SIZE];
  10. char buffer2[BUFFER_SIZE];
  11. char * buffers[2];
  12. unsigned ibuffer = 0;
  13. unsigned first = 1;
  14. buffers[0] = buffer1;
  15. buffers[1] = buffer2;
  16. while (fgets(buffers[ibuffer], BUFFER_SIZE, stdin))
  17. {
  18. if (first)
  19. {
  20. first = 0;
  21. fputs(buffers[ibuffer], stdout);
  22. ibuffer ^= 1;
  23. }
  24. else
  25. {
  26. if (strcmp(buffers[ibuffer], buffers[ibuffer ^ 1]) != 0)
  27. {
  28. fputs(buffers[ibuffer], stdout);
  29. ibuffer ^= 1;
  30. }
  31. else
  32. {
  33. /* do nothing */
  34. }
  35. }
  36. }
  37. }
  38. int __cdecl main()
  39. {
  40. Unique();
  41. return 0;
  42. }