c++ Programming Glossary: buf
What do the following phrases mean in C++: zero-, default- and value-initialization? http://stackoverflow.com/questions/1613341/what-do-the-following-phrases-mean-in-c-zero-default-and-value-initializat C m ~C int m non POD default initialising m int main char buf sizeof B memset buf 0x5a sizeof buf use placement new on the.. default initialising m int main char buf sizeof B memset buf 0x5a sizeof buf use placement new on the memset'ed buffer to.. m int main char buf sizeof B memset buf 0x5a sizeof buf use placement new on the memset'ed buffer to make sure if we..
What uses are there for “placement new”? http://stackoverflow.com/questions/222557/what-uses-are-there-for-placement-new new operator which constructs an object on a pre allocated buffer. This is useful when building a memory pool a garbage collector.. allocated and constructing an object on a pre allocated buffer takes less time char buf new char sizeof string pre allocated.. an object on a pre allocated buffer takes less time char buf new char sizeof string pre allocated buffer string p new buf..
Output unicode strings in Windows console app http://stackoverflow.com/questions/2492077/output-unicode-strings-in-windows-console-app SetConsoleOutputCP CP_UTF8 wchar_t s L èéø ǽл Σæ a int bufferSize WideCharToMultiByte CP_UTF8 0 s 1 NULL 0 NULL NULL char.. CP_UTF8 0 s 1 NULL 0 NULL NULL char m new char bufferSize WideCharToMultiByte CP_UTF8 0 s 1 m bufferSize NULL NULL.. m new char bufferSize WideCharToMultiByte CP_UTF8 0 s 1 m bufferSize NULL NULL wprintf L S m However I did not find any way..
Can I use a binary literal in C or C++? http://stackoverflow.com/questions/2611764/can-i-use-a-binary-literal-in-c-or-c std int main unsigned short b BOOST_BINARY 10010 char buf sizeof b 8 1 printf hex 04x dec u oct 06o bin 16s n b b b itoa.. b 8 1 printf hex 04x dec u oct 06o bin 16s n b b b itoa b buf 2 cout setfill '0' hex hex setw 4 b dec dec b oct oct setw..
What are Aggregates and PODs and how/why are they special? http://stackoverflow.com/questions/4178175/what-are-aggregates-and-pods-and-how-why-are-they-special example assumes T is a POD type #define N sizeof T char buf N T obj obj initialized to its original value memcpy buf obj.. buf N T obj obj initialized to its original value memcpy buf obj N between these two calls to memcpy obj might be modified.. these two calls to memcpy obj might be modified memcpy obj buf N at this point each subobject of obj of scalar type holds its..
C++ SMTP Example http://stackoverflow.com/questions/58210/c-smtp-example sockaddr_in server struct hostent hp gethostbyname char buf BUFSIZ 1 int len char host_id 192.168.1.10 char from_id rameshgoli@domain.com.. a string from the socket void read_socket len read sock buf BUFSIZ write 1 buf len printf Server s n buf MAIN int main.. socket void read_socket len read sock buf BUFSIZ write 1 buf len printf Server s n buf MAIN int main int argc char argv..
how to find the location of the executable in C http://stackoverflow.com/questions/933850/how-to-find-the-location-of-the-executable-in-c straight and realiable way is to readlink proc self exe buf bufsize Linux readlink proc curproc file buf bufsize FreeBSD.. and realiable way is to readlink proc self exe buf bufsize Linux readlink proc curproc file buf bufsize FreeBSD readlink.. proc self exe buf bufsize Linux readlink proc curproc file buf bufsize FreeBSD readlink proc self path a.out buf bufsize Solaris..
|