'분류 전체보기'에 해당되는 글 131건

  1. 2017.02.26 다 먹고 살자고 하는일인데 by 뉴암스테르담
  2. 2017.02.18 제일 큰 불효라 by 뉴암스테르담
  3. 2015.08.17 console output formatting by 뉴암스테르담 2
  4. 2015.08.17 beginthreadex_ by 뉴암스테르담
  5. 2015.08.16 race condition by 뉴암스테르담
  6. 2015.08.14 토수아울렛 by 뉴암스테르담
  7. 2015.08.13 ㅇㅇ by 뉴암스테르담
  8. 2015.08.12 나 이거 절대 공감이다 ... 기사보다 제목 by 뉴암스테르담
  9. 2015.08.12 세상 모든 일은 명분과 실리이다.. by 뉴암스테르담
  10. 2015.08.12 서브넷 마스크에 대한 문제 by 뉴암스테르담

머 이리 못잡아 먹어서 안달일까

Posted by 뉴암스테르담
l

다른것 보다 자식이 먼저 죽는게 제일 큰 불효라던데 ... 아마도 그렇게 될 가능성이 높다는게 .. 마음이 아프다

Posted by 뉴암스테르담
l

console output formatting

 Jun 11, 2010 at 8:28pm
I am sorry, but I need a quick help

what would be analog to this function in C to C++
printf("%5d", var)

cout << var ?????????
but how to format it to take 5 places in console ?
 Jun 11, 2010 at 8:36pm
printf("%5d", var) will work in C++. Most C functions, at least all C functions i know, work in C++
 Jun 11, 2010 at 8:54pm
you must include <cstdio> and it works printf("%5d", var);
Last edited on Jun 11, 2010 at 8:55pm
 Jun 11, 2010 at 11:40pm
Neither answers his question, however...

To do that in C++, #include <iomanip> and use the following construct:

cout << setw( 5 ) << var;

Hope this helps.
 Jun 11, 2010 at 11:59pm
This reluctance to adopt C++ constructs is far too common. It's a pet peeve of mine.
 Jun 12, 2010 at 12:11am
Honestly, I still think printf/etc is easier (as in less typing, easier to remember the codes) than the iostream counterparts. Especially since iostream doesn't seem to remember the last modifiers you give it.

1
2
3
4
5
6
7
8
9
// print 2 numbers 'a' and 'b' in 0xAAAABBBB (hex) format
cout << "0x" << hex << uppercase << setw(4) << setfill('0') << a
             << hex << uppercase << setw(4) << setfill('0') << b << endl;

// vs.
printf("0x%04X%04X\n",a,b);

// or if you want more clarity
printf("0x" "%04X" "%04X" "\n",a,b);


The iostream approach is even more horrifying if you you're not using the "using" directive.


I'm not discounting the merits of iostream. I know that it's better in a lot of ways (and why). I'm just showing why so many people are still reluctant to use it.
Last edited on Jun 12, 2010 at 12:15am
 Jun 12, 2010 at 9:25pm
I disagree.

The reason people use C stuff over C++ stuff is because they have already been contaminated with C.

The C counterpart doesn't remember the last modifier you give it either.

The only thing that can be said against iostream is that it is more verbose...
 Jun 12, 2010 at 11:52pm
Wait, I never learnt C and I still prefer cstdio over iostream in some situations. Terseness is one reason, but the other is that "%08X" is much easier to remember than <<std::setw(8)<<std::setfill('0')<<std::hex. I often find it preferable to just sprintf() to an array than go look up voodoo incantations. Sure, it's laziness, but what exactly am I loosing, other than consistency?
 Jun 13, 2010 at 12:43am
It might be nice to have a manipulator to configure the stream output according to cstdio formatting rules:

 
std::cout << std::cformat("%08X") << ... etc
 Jun 13, 2010 at 2:56am
Duoas wrote:
The C counterpart doesn't remember the last modifier you give it either.


But repeating the format for the C counterpart doesn't involve a full line of text. It's just 4-6 characters tops.

Duaos wrote:
The only thing that can be said against iostream is that it is more verbose...


You say that like it's insignificant. For some things I guess it's not a big deal, but for writing trace logs and stuff where you're dumping lots of data, it's quite a big deal.

Galik wrote:
It might be nice to have a manipulator to configure the stream output according to cstdio formatting rules:


I've thought about that more than once. The thing is it kind of defeats half the point of using iostream.

cstdio's 2 big problems are:
- type safety
- having to parse a format string

By having a cformat() manipulator you're reintroducing half of the problems iostream solves.

Plus, I don't think there's an iostream equivilent of %g, but I might be wrong on that.


Another idea would be to make modifiers for common output formats. Like:

1
2
std::cout << std::c08X << ...
std::cout << std::c04X << ...


But that would require you to write lots of modifiers.

'SYSTEM PROGRAMMING' 카테고리의 다른 글

race condition  (0) 2015.08.16
서브넷 마스크에 대한 문제  (0) 2015.08.12
IP 주소로의 여행  (0) 2015.08.11
경계적 대기 - win32 multihthreading  (0) 2015.08.11
기초적 쓰레드 동기화  (0) 2015.08.10
Posted by 뉴암스테르담
l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// input your code here
bool Network::InitNetworkWindows()
{
#ifdef __linux__
#else
    unsigned int i;
    if (WSAStartup(MAKEWORD(22), &wsaData_) != 0)
    {
        CLog::WriteLog(LOG_TYPE::LOG_TYPE_EXIT, "WSAStartup () Error");
        return false;
    }
 
    hComPort_ = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 00);
    GetSystemInfo(&sysInfo_);
 
    for (i = 0; i < sysInfo_.dwNumberOfProcessors; i++)
    {
        _beginthreadex(NULL, 0, [](void* arg) ->unsigned int{
            HANDLE hComPort = (HANDLE)arg;
            SOCKET sock;
            DWORD bytesTrans;
            LPPER_HANDLE_DATA handleInfo;
            LPPER_IO_DATA ioInfo;
            DWORD flags;
 
            while (1){
                GetQueuedCompletionStatus(hComPort, &bytesTrans, (LPDWORD)&handleInfo, (LPOVERLAPPED*)&ioInfo, INFINITE);
 
                sock = handleInfo->hClntSocket;
                if (ioInfo->rwMode == READ)
                {
                    CLog::WriteLog(LOG_TYPE::LOG_TYPE_DEBUG, "message received");
 
                    if (bytesTrans == 0)
                    {
                        closesocket(sock);
                        free(handleInfo);
                        free(ioInfo);
                        continue;
                    }
 
                    memset(&(ioInfo->overlapped), 0sizeof(OVERLAPPED));
                    ioInfo->wsaBuf.len = bytesTrans;
                    ioInfo->rwMode = WRITE;
                    WSASend(sock, &(ioInfo->wsaBuf), 1, NULL, 0&(ioInfo->overlapped), NULL);
 
 
                    ioInfo = (LPPER_IO_DATA)malloc(sizeof(PER_IO_DATA));
                    memset(&(ioInfo->overlapped), 0sizeof(OVERLAPPED));
 
                    ioInfo->wsaBuf.len = BUF_SIZE;
                    ioInfo->wsaBuf.buf = ioInfo->buffer;
                    ioInfo->rwMode = READ;
 
                    WSARecv(sock, &(ioInfo->wsaBuf), 1, NULL, &flags, &(ioInfo->overlapped), NULL);
                }
                else
                {
                    puts("message sent!");
                    free(ioInfo);
                }
            }
 
            return 0;
        } , (LPVOID)hComPort_, 0, NULL);
    }
 
#endif
 
 
    return 0;
}
cs

'PROGRAMMING/ALGORITHM' 카테고리의 다른 글

C++ MEMORY POOL  (0) 2015.08.06
Posted by 뉴암스테르담
l

race condition

SYSTEM PROGRAMMING 2015. 8. 16. 12:42

경쟁조건

'SYSTEM PROGRAMMING' 카테고리의 다른 글

console output formatting  (2) 2015.08.17
서브넷 마스크에 대한 문제  (0) 2015.08.12
IP 주소로의 여행  (0) 2015.08.11
경계적 대기 - win32 multihthreading  (0) 2015.08.11
기초적 쓰레드 동기화  (0) 2015.08.10
Posted by 뉴암스테르담
l

http://m.blog.daum.net/_blog/_m/articleView.do?blogid=0JqSr&articleno=2606272

Posted by 뉴암스테르담
l

ㅇㅇ

나만 좋으면 되 2015. 8. 13. 05:55

http://viral-contents.info/10-most-evil-women-in-the-history/2/

Posted by 뉴암스테르담
l

http://www.wsj.com/articles/BL-229B-21079?mobile=y

Posted by 뉴암스테르담
l

그러하다.. 명분을 내줬으면 실리를 받는거고 실리를 얻으려면 상대방에게 명분을 내주는 것이다.


but ...


무슨짓을 해서든 성공시켜야 한다며...   성추행 했던 놈을" 해고가 맞지만,  성공하려면 반드시 필요한 사람"이라고 감싸준 그 순간 부터 


명분이고 실리고  모두 날라갔던 거다..  



그건 진심으로 후회한다...  내가 눈이 멀었었다. 


                                         

justification & practical benefits.




Posted by 뉴암스테르담
l
  1. C 클래스 네트워크를 24개의 서브넷으로 나누려고 한다. 각 서브넷에는 4~5개의 호스트가 연결되어야 한다.  어떤 서브넷 마스크가 적절한가?
    1. 255.255.255.192
    2. 255.255.255.224
    3. 255.255.255.240
    4. 255.255.255.248
  2. IP 주소가 128.110.121.32(255.255.255.0) 이라면 네트워크 주소는 어떻게 되는가?   
    1. 128.0.0.1
    2. 128.110.0.0
    3. 128.110.121.0
    4. 129.110.121.32
  3. IP 주소 203.10.24.27이란 호스트의 서브넷 마스크의 255.255.255.240 이다. 이때 이 네트워크의 호스트 범위와 브로드캐스는 주소는 어떻게 되는가?
    1. 호스트 203.10.24.16~ 203.10.24.32,    브로드 캐스트  203.10.24.32
    2. 호스트 203.1.24.1 ~ 203.10.24.254     브로드 캐스트  203.10.24.255
    3. 호스트 203.10.24.17 ~ 203.10.24.31    브로드 캐스트  203.10.24.32
    4. 호스트 203.10.24.27 ~ 203.10.24.30    브로드 캐스트  203.10.24.31
  4. 클래스 B 주소를 가지고 서브넷 마스크 255.255.255.240 으로 서브넷 을 만들었으때 나오는 서브넷의 수와 호스트의 수가 맞게 짝지어 진것은?
    1. 서브넷 2048 / 호스트 14
    2. 서브넷 14   / 호스트 2048
    3. 서브넷 4094 / 호스트 14
    4. 서브넷 254  / 호스트 254
    5. 서브넷 254 / 호스트 8190
  5. C클래스 네트워크를 24개의 서브넷으로 나누려고 한다.  각 서브넷에는 4~5개의 호스트가 연결되어야 한다. 어떤 서브넷 마스크가 적절한가?
    1. 255.255.255.192
    2. 255.255.255.224
    3. 255.255.255.240
    4. 255.255.255.248



  1. 공인 IP 주소를 210.110.1.0 ( 서브넷 마스크 255.255.255.0 == ) 네트워크를 받았습니다.  그런데 네트워크 관리자인 여러분은 이 공인 주소를 이용해서 PC 30 대인 네트워크를 최소 4개 이상 만든 다음 네트워크를 라우터를 이용해서 통신하려고 합니다. 
    이 경우 ,  여러분이 서브넷 마스크를 만든다면 어떻게 해야 할까요?
  2. 일단 우리가 가지고 있는 공인 주소는 201.2225.5.0( 2


'SYSTEM PROGRAMMING' 카테고리의 다른 글

console output formatting  (2) 2015.08.17
race condition  (0) 2015.08.16
IP 주소로의 여행  (0) 2015.08.11
경계적 대기 - win32 multihthreading  (0) 2015.08.11
기초적 쓰레드 동기화  (0) 2015.08.10
Posted by 뉴암스테르담
l