태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.
블로그 이미지
하늘을 헤엄치다. revoman

카테고리

분류 전체보기 (176)
Eye (13)
Programming (82)
Unix & Linux (52)
Android (3)
Tool and Tip (13)
시스템 관리 (7)
OPEN SOURCE (2)
XML (1)
WEB (0)
MY PROGRAM (1)
정보관리기술사 기출.. (1)
IT 동향 (1)
Total56,866
Today6
Yesterday34

출처 : http://c-faq.com/osdep/baton.html


Q: How can I display a percentage-done indication that updates itself in place, or show one of those ``twirling baton'' progress indicators?


A: These simple things, at least, you can do fairly portably. Printing the character '\r' will usually give you a carriage return without a line feed, so that you can overwrite the current line. The character '\b' is a backspace, and will usually move the cursor one position to the left.


Using these characters, you can print a percentage-done indicator:


  1.     for(i = 0; i < lotsa; i++) {
  2.         printf("\r%3d%%", (int)(100L * i / lotsa));
  3.         fflush(stdout);
  4.         do_timeconsuming_work();
  5.     }
  6.     printf("\ndone.\n");


or a baton:


  1.     printf("working: ");
  2.     for(i = 0; i < lotsa; i++) {
  3.         printf("%c\b", "|/-\\"[i%4]);
  4.         fflush(stdout);
  5.         do_timeconsuming_work();
  6.     }
  7.     printf("done.\n");

이 글은 스프링노트에서 작성되었습니다.

Posted by revoman
TAG c-faq

출처 : http://c-faq.com/misc/endiantest.html


Q: How can I determine whether a machine's byte order is big-endian or little-endian?

A: The usual techniques are to use a pointer:

  1.     int x = 1;
  2.     if(*(char *)&x == 1)
  3.         printf("little-endian\n");
  4.     else    printf("big-endian\n");


or a union:

  1.     union {
  2.         int i;
  3.         char c[sizeof(int)];
  4.     } x;
  5.     x.i = 1;
  6.     if(x.c[0] == 1)
  7.         printf("little-endian\n");
  8.     else    printf("big-endian\n");


Posted by revoman
TAG c-faq

최근에 달린 댓글

최근에 받은 트랙백

글 보관함