Description:
Discussion about C.
|
|
|
offsetof-style Fun with Ternary Conditional
|
| |
A possibly interesting/curious use of the ternary conditional operator... The only thing I could find to do with it was the non-portable: ... (1 ? 0 : &(x)) ... ((size_t)&(NULL_OF_TYPE(id)->m ember)) int main(void) { struct { double bar; long baz; } foo; return (int)offsetof2(foo, baz);... more »
|
|
Proposal for Amendment to Section 6.5.3.2, Unary * Operator
|
| |
A proposal for an amendment of C99's section 6.5.3.2 follows: --- AMENDMENT --- 6.5.3.2 Address and indirection operators Constraints 1 <NO AMENDMENT PROPOSED> 2 The operand of the unary * operator shall have pointer type. <NO AMENDMENT PROPOSED> 3 Except when the unary * operator and its operand are not evaluated,... more »
|
|
Why is it not possible to assign a global variable to another global variable..?
|
| |
say .. I have a peice of code like, i = 10 ; z = i ; <---------all are global scope.. main() ---- --- but not allowing me to compile and get a.out .. Then i did, int i , z ; i = z = 20 ; multiple varibles initialization in global scope.. main () ------ ------ which is also not working.. but multiple initializations in local scope...is working...... more »
|
|
MIDI files in C(lccwin/WIN XP)
|
| |
Hi Can anybody tell me you to play MIDI file through a C program ? i am using lccwin for WinXP Decoding the midi file and then play it by directly interfacing with speakers using inportb() function in conio.h or sound() function in dos.h. is it possible or not and if possible then HOW TO DECODE MIDI FILE ?... more »
|
|
file functions
|
| |
fseek() fgetpos() and fsetpos() work this way if I understand and please anyone correct me if I'm wrong. fseek() reading from origin and reads addresses and f*pos get and puts the file pointer to a value at any address? I want to read bytes in a file stream up from JUNK in a .avi file to LIST.... more »
|
|
Simulate usb device
|
| |
I have to read/write on a usb device, where we normally attach things that I don't have always available. Since this usb connection only forwards data it would be theoretically the same if I write and read over a file. But how do I simulate the serial (usb) interface? My collegue told me there some kind of acknowledgement needed for that.... more »
|
|
Dropping privileges
|
| |
My program now sadly runs only as root, but actually I think that the only thing that really needs root access is the creation of a tunnel device. Looking around I understood that I could use setuid() to drop the privileges after critical part is over, but to what user? I think this is the reason why mysql/openldap/etc creates new user, so... more »
|
|
manipulate fd underlying stream
|
| |
comp.lang.c FAQ 12.33 says: ...Hmmm ... ...Why not leave the stream unchanged, and manipulate its underlying file descriptor: a) fflush() the stdio stream b) dup the stdio fd to an unused fd, saving a copy of it. c) close the stdio fd d) use open() to get an fd for the desired file, and compare the fd... more »
|
|
Structs of arbitrary size?
|
| |
I think I know the answer to this is "no", but I'll ask anyway. Is it possible to define a struct of arbitrary size as a parameter to a routine, with its size passed in as another parameter or parameters? By this, I mean something like this: int foo(struct A *ptr; int size1, int offset, int size2) {... more »
|
|
invalid single quote
|
| |
Hi all, I'm reading the book 'ANSI and ISO Standard C' by Plauger and Bordie. At a point i read an example like this: ...char *str1 = tostring(O'Reilly); /* invalid */ char *str2 = "O'Reilly"; /* valid */ The book says: 'Any character standing alone *other* than one from the basic C character set forms a... more »
|
|
|