Adam Rosenfield

United States

adamrosenfield.com

Age: 28

Software engineer from Cambridge, MA

Dec
15
awarded Necromancer
Dec
14
comment How to store a socket within a list C++
Sockets are just plain ints in C/C++.
Dec
12
awarded Nice Answer
Dec
8
answered C++ mktime returning random dates
Dec
6
awarded Enlightened
Dec
4
awarded Great Answer
Dec
1
comment use macro to define two local variable but have the same address
True, statement expressions are not standard C and the program is not technically legal C in that respect. But even in the extended (ISO C + GCC extensions) model, it's still UB because GCC documents these objects as being temporary and destroyed when the statement expression ends. So doing char *x = ({char y[16] = {0}; y;}); is just as much UB as char *foo() { char y[16] = {0}; return y; } ... char *x = foo();.
Dec
1
comment use macro to define two local variable but have the same address
In particular, this is Undefined Behavior because the array decays to a pointer to its first element, and it's not legal to use a pointer to an object after it's been destroyed. The result of this UB happens to manifest itself as two objects which have the same address in memory, but the UB could easily manifest in crashes or other strange behavior, or appearing to work correctly.
Nov
30
comment error C2371, redefinition; different basic types
Never use gets(). Never use gets(). It is impossible to use safely.
Nov
30
revised Unhandled exception at : Access violation reading location error while implementing graphs
added 16 characters in body
Nov
29
reviewed Approve suggested edit on C - Seemingly unsigned int being sign extended when right shift?
Nov
29
comment C - Seemingly unsigned int being sign extended when right shift?
How are you getting 536870912? I get the expected value of 67108864 (ideone.com/aIcOJ3), which is 1 << 26.
Nov
28
comment Android Material Design Inline Datepicker issue
Gee, thanks Google for taking existing working code and completely breaking it on new versions of Android! This isn't even source code compatibility, it's binary compatibility they broke.
Nov
28
awarded Informed
Nov
25
comment Write to existing named pipe via Python
What do you mean by "doesn't work"? What happens, and what did you expect to happen? Note that when you open a named pipe for reading or writing, that open() call blocks until another process opens the other end of the pipe; see mkfifo(3).
Nov
21
comment How to covert std::string to NSString?
What character encoding is your string using? If care is used and you know your encodings, std::string can be used with Unicode, but it's messy.
Nov
21
answered Determining endianness at compile time
Nov
20
comment What are the 15 classifications of types in C++?
Maybe you should ask Walter E. Brown? Whatever he's talking about, it's not something specifically spelled out in the C++ language spec.
Nov
20
comment Error expected ';' before 'cout'
The compiler is expecting a semicolon before the reference to cout on line 17. What's not to understand about that? Have you looked at what's before line 17?
Nov
18
comment Storing an api_key, api_pass
Encrypt them with a symmetric key (with a real encryption algorithm like AES, not with XOR), and then store that symmetric key securely external to the database, so that if the database is compromised (say, through a SQL injection vulnerability), the passwords aren't compromised.
1 2 3 4 5