C - Need to compare n lowest bits of an int for equality.
I.e. n = 4;
xxxx1001 == xxxx1001 (x is don't care)
I.e. n = 2;
xxxxxx01 == xxxxxx01
Can't think of a nice way to do it without using masks, =).
...
What are all operations supported by function pointer differs from raw pointer?
Is > , < , <= , >=operators supported by raw pointers if so what is the use?
...
I need some help with this, since it baffles me in my C program
I have 2 strings(base, and path)
BASE: /home/steve/cps730
PATH: /page2.html
this is how printf reads then just before I call a sprintf to join their content together. here is the code block
int memory_alloc = strlen(filepath)+1;
memory_alloc += strlen(B...
I know there are many tutorials out there for getting started in C. However Its hard for me to apply the knowledge. The way I've always started out in languages is by writing scripts. Of course C is not a scripting language.
My question isn't so much about learning C as much as it is about how to get started applying C. Great I can wri...
Any links to code to get the control tree? Thanks.
...
I need to do some simple DES encryption in C to interface with some old code. From what I understand you can use the "crypt" library for this, with the functions setkey, encrypt, crypt, etc. I have been messing with it and can't get it right. The example on the man page for setkey/encrypt is lacking.
I want to get the same output as I w...
u32 iterations = 5;
u32* ecx = (u32*)malloc(sizeof(u32) * iterations);
memset(ecx, 0xBAADF00D, sizeof(u32) * iterations);
printf("%.8X\n", ecx[0]);
ecx[0] = 0xBAADF00D;
printf("%.8X\n", ecx[0]);
free(ecx);
Very simply put, why is my output the following?
0D0D0D0D
BAADF00D
ps:
u32 is a simple typedef of unsigned int
edit:
...
Is there a way to view C code "live", by displaying the current current line, as it is being executed?
You can pretty close by using GDB, but I'm wondering if there is something slightly more elegant than holding the return key down:
$ gdb ./mycode
(gdb) break 1
Breakpoint 1 at 0x100000f08: file mycode.c, line 1.
(gdb) run
Starting pro...
Is there such a thing as dangerous knowledge when just starting out learning C or C++? In other words what is the likelihood that I could "accidently" write and compile a code snippet that formats the hard drive, renders the OS unusable, or worse case scenario silently deletes random files on the computer?
Stuff like the veritable
fo...
I am thinking about changing my formatting style. I have been doing this:
char *foo(IULabel *label, char *buffer) {
UITextView *tv;
int i;
int *j;
...
}
and I am thinking that it might be easier to understand if I were to write:
char * foo(IULabel * label, char * buffer) {
UITextView * tv;
in...
I am writing a LLVM code generator for the language Timber, the current compiler emits C-code. My problem is that I need to call C functions from the generated LLVM files, for example the compiler has a real-time garbage collector and i need to call functions to notify when new objects are allocated on the heap. I have no idea on how to ...
Hi,
please, could someone explain to me a few basic things about working with languages like C? Especially on Windows?
If I want to use some other library, what do I need from the library? Header files .h and ..?
What is the difference between .dll and .dll.a.? .dll and .lib? .dll and .exe? What is .def?
Does it matter how was the lib...
Is there an event fired when screensaver starts? Like for keychain locking:
OSStatus keychain_locked(SecKeychainEvent keychainEvent, SecKeychainCallbackInfo *info, void *context){...}
...
After reading this article on thedailywtf.com, I'm not sure that I really got the joke.
It says there that some guy changed the code from
int function()
{
int x;
char data_string[15];
...
x = 2;
strcpy(data_string,"data data data");
...
}
to
int function()
{
int x = 2;
char data_string[15] = "data data data";
.....
I can't understand the operation of the "readlink" systemcall in Linux.
Can anyone explain about it with simple example on it?
...
Is the following code legal?
char* randomMethod1() {
char* ret = "hello";
return ret;
}
and this one?
char* randomMethod2() {
char* ret = new char[10];
for (int i = 0; i < 9; ++i) {
ret[i] = (char)(65 + i);
}
ret[9] = '\0';
return ret;
}
I'd say the first one is legal, as what you are actually...
Hello,
I would like to ask in more detail about a answer I recently got here (3rd one):
Compiled languages basics
If I write in C and MinGW and I link to C++ library compiled by VC - will it work? How do I know in advance?
In other words, if I'm able to create without warnings an .exe which links to that C++ .dll, and I'm able to run ...
Hi
I want to programatically [in C] calculate CPU usage % for a given process ID in Linux.
How can we get the realtime CPU usage % for a given process ??
To make it further clear -
I should be able to determine the CPU usage for the provided processid or process.
The process need not be the child process.
I want the solution in...
Does it? If yes, where can I get the documentation for it... if not, then which would be the best alternative?
...
I've been learning C at Varsity for just shy of 2months now, and next year we'll be moving on to C++.
Are there any habits I should get into with my C programming which will aid a transition to C++ in the future, or is it best to think of them completely separately ?
When you learnt C then C++, did the way you coded in C change in an...