Possible Duplicates:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc)
How do we explain the result of the expression (++x)+(++x)+(++x)?
Why does the following program print 10? Isn't it supposed to print 12?
int j=2;
j = j++ * ++j;
printf("%d", j);
...
Hi,
I didn't used C for a lot of time, and now I have to modify a little piece of code. There one thing I can't understand:
char filename[20];
filename[0] = '\0';
for (j=0; j < SHA_DIGEST_LENGTH; j++){
sprintf(filename + strlen(filename),"%02x",result[j]);
}
In the first line a string of 20 characters is dleclared.
In the second li...
Hi all,
im trying to use FIT (CppFIT) to test some C programs.
But I'm not able to configure it right.
Could someone help me to understand, how FIT for C works? How can I connect my program
with a fixture? How can I start FIT Runner?
I made some examples with java and they run.
Thanks all! :)
...
I want to know how a static variable or function is protected to be used only for the file it is defined in. I know that such variables and functions are declared in data section (heap area to be precise), but is it tagged with the file name ? Suppose I make a fool of the compiler by assigning such a static function (defined in foo.c) to...
I am writing some C code which is expected to compile on multiple compilers (at least on MSVC and GCC). Since I am beginner in C, I have all warnings turned on and warnings are treated as errors (-Werror in GCC & /WX in MSVC) to prevent me from making silly mistakes.
When I compiled some code that uses strcpy on MSVC, I get warning lik...
how do i make a 160*70 bitmap image move over a 640*280 bitmap image and reflect off its edge after converting both bitmap images into yuv 4:4:4and write it into a single yuv file ? and how do i convert the same into yuv 4:2:0?could you please help me out as to how do i code the same in c?
...
Can anybody give pointers how I can implement lzw compression/decompression in low memory conditions (< 2k). is that possible?
...
i am interested on this problem
Interleave bits the obvious way
(from http://graphics.stanford.edu/~seander/bithacks.html)
unsigned short x; // Interleave bits of x and y, so that all of the
unsigned short y; // bits of x are in the even positions and y in the odd;
unsigned int z = 0; // z gets the resulting Morton Number.
...
I am right now pretty experienced with scripting languages, especially Ruby, JavaScript and PHP. Now I want to learn some more powerful languages and I think C# is the best choice for me. After that I'd like to learn C, because most of the people say it's a “must-have” and that it gives you a better understanding of programming. Maybe I ...
Hi folks,
I'm working on a little (not so little actually) project in C (ref. this question) , and I need a little function in C that'd generate a unique and random string.
I need a small one that I can include as a utility function in a .c file.
Please help me with your brains, and show me how smart this could be done!
Thanks and a v...
Hi,
I'm working with an old C code that still has a few dusty corners. I'm finding a lot of #ifdef statements around that refer to operating systems, architectures, etc. and alter the code for portability. I don't know how many of these statements are still relevant today.
I know that #ifdef isn't the best idea in certain circumstance...
Can anyone point me to a reference on how to implement the factory pattern using ANSI C? If more patterns are covered to that would just be a bonus. Doing this in C++ i trivial for me, but since C does not have classes and polymorphism I'm not quite sure how to do it. I was thinking about having a "base" struct with all the common data t...
How do I get the ASCII value as an int of a character in Cocoa? I found an answer for doing this in python, but I need to know how to do this in Cocoa. ( I am still a noob in Cocoa).
Python method:
use function ord() like this:
>>> ord('a')
97
and also chr() for the other way around:
>>> chr(97)
'a'
how do I do this in Cocoa?...
Very often you have a function, which for given arguments can't generate valid result or it can't perform some tasks. Apart from exceptions, which are not so commonly used in C/C++ world, there are basically two schools of reporting invalid results.
First approach mixes valid returns with a value which does not belong to codomain of a f...
I'm trying to find proper way to handle stale data on NFS client. Consider following scenario:
Two servers mount same NFS shared storage with number of files
Client application on 1 server deletes some files
Client application on 2 server tries to access deleted files and fails with: Stale NFS file handle (nothing strange, error is ex...
hello,
So I'm writing some C code to connect to a server that is expecting me to provide a certificate for authentication. I'm using OpenSSL to do the SSL communications and I've got the socket code worked out, and I have code to do the SSL part worked out to, but what I can't seem to get simply because the docs are so sparse is how to ...
Heres my code:
void *PrintLine(void *line)
{
printf("Line: #%s\n", (char *)line);
pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
char line[80];
while(fgets(line,sizeof(line),fp))
{
pthread_create(&threads[rt], NULL, PrintLine, (void*)line);
}
fclose(fp);
}
Please dont tell me that runnin...
There is a server which sends some data in Octet strings. For example it is sending
00405080065233E
like this, then I need to convert this into a string and store it into a buffer.
If I decode that converted string it has give the same 000405080065233E octet string again.
How can I do this? Can anybody suggest some solution?
...
I'm updating some old old code (that works for now, but is using OpenTransport, so um... no) that interfaces with a USB scanner. I THINK I understand how IOUSBDeviceInterface and IOUSBInterfaceInterface are supposed to work, but I can't seem to get information about the pipes.
I have a method which takes: (IOUSBInterfaceInterface **)int...
This was an actual interview question. o_O
Let's leave aside the issues of asking such a question in an interview.
I'm wondering what alternatives to the ol' TCP sockets approach are readily available (as libraries, for instance), for use in C or C++.
I'm making no assumptions on platform, compiler etc - take your pick.
I'm not as...