Since our applications run in fullscreen mode, we have developed a keyboard hooking driver to disable user input for keys like ALT+F4, CTRL+ALT+DEL and so forth.
The driver is developed in C using the Windows Driver Kit.
Compiling for 32-Bit works and it loads the driver on Windos 7 32-Bit and it works as expected.
Compiling for 64-Bi...
I'm trying to read binary data in a C program with read() but EOF test doesn't work. Instead it keeps running forever reading the last bit of the file.
#include <stdio.h>
#include <fcntl.h>
int main() {
// writing binary numbers to a file
int fd = open("afile", O_WRONLY | O_CREAT, 0644);
int i;
for (i = 0; i < 10; i++) {
wr...
I'm using multithreading in my application with _beginthread and right now to wait until all threads are done I have global bools that get set to true as each thread completes so I'm in a while loop until then. There must be a cleaner way of doing this?
Thanks
...
The code below is from this answer:
#include <windows.h>
int main()
{
HANDLE h = ::CreateFile(L"\\\\.\\d:", 0, 0, NULL, OPEN_EXISTING, 0, NULL);
STORAGE_DEVICE_NUMBER info = {};
DWORD bytesReturned = 0;
::DeviceIoControl(h, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &info, sizeof(info), &bytesReturned, NULL);
}
Whe...
In PHP I can do it as simple as :
file_get_contents('http://stackoverflow.com/questions/ask');
What's the shortest code to do the same in C?
UPDATE
When I compile the sample with curl, got errors like this:
unresolved external symbol __imp__curl_easy_cleanup referenced in function _main
...
I've recently installed "klocwork" and am trying to get rid of bugs on an existing code.
The error shown seems to be simple. No null at the termination of the char * _p_.
I have manually added a null termination (even though there is no need), but it doesn't please the Klocwork. Any ideas?
The exact message is:-
Incorrectly termin...
Hi,
I have a question and I tried to think over it again and again... but got nothing so posting the question here. Maybe I could get some view-point of others, to try and make it work...
The question is: we are given a SORTED array, which consists of nos. which occur EVEN no. of times, except one, which occurs ODD no. of times. We nee...
Hey;
I am reading a binary file. and when it reaches the end. it seems it is terminated by feof() function. is it because there is no EOF character for binary files? if so how can i solve it.
currently my code is using a while loop
while (!feof(f))
when it reaches the end of file at position 5526900. it doesn't stop. it just keeps...
Hello,
Note: Despite the mentioning of Python in the following there is a good chance for my problem not to be Python related at all. If I am not mistaken the “module” I mention is equivalent to a C library—at least for the concerns of my problem.
On Debian I am trying to create a Python module with C, which in turn uses the GSL. The f...
I am developing in C++ using Boost.Asio. I want to be able to base64 decode data and since Boost.Asio links to openssl I want to use it's functions to do so and not add an extra dependency(eg crypto++). I have found this code here that shows how to do it. (change int finalLen = BIO_read(bmem, (void*)pOut, outLen); to inLen )
I don't kno...
Take look at the code that follows.
"Hello " "World!";
"The number is ", 37;
int x=23;
char *y="232";
x,x+2,x*3;
atoi(y) - x;
It is a perfectly valid fragment of C(99) source.
But! All that expressions return to nowhere!
How can one trace or even use all this anonymous values?
Where are they stored and what is their purpose?
...
While writing a simple server-client application, this question came in my mind. When someone tries to write to a broken pipe, a SIGPIPE would be generated. Let's say I handle the signal in my code.
Now what error does the write call returns - EPIPE or EINTR ( as it was interrupted by a signal). I tried with a sample program and I seem ...
Do they repeatedly check for the condition and execute if the condition is met. Ex, how the OS knows exactly when a USB device is plugged in, or how MSN knows exactly when you get an email. How does this work?
Thanks
...
if I use the following code...
message = TTF_RenderText_Solid( font, "Lorem Ipsum", textColor );
Do I need to free message before I can do this
message = TTF_RenderText_Solid( font, "Lorem Ipsum part 2", textColor );
i.e. does it give me a new surface (and so I have to clean up the old one) or does it just blit over the old one?
...
In particular, will the following ever not work as expected:
typedef void(*func_p)(void*);
void foo(int* data)
{
printf("%i\n",*data);
}
int main(int argc, char** argv)
{
func_p bar;
int x = 42;
bar = foo;
bar((void*)&x);
return 0;
}
ie, can I rely on data pointers (void*, int*, struct baz*,...
I'm trying to write a PAM module. The PAM module creates a directory on first log in. Very similar to the pam_mkhomedir.
Here is the code.
PAM_EXTERN int
pam_sm_open_session (pam_handle_t *pamh, int flags, int argc,
const char **argv)
{
int retval;
const char *user;
const struct passwd *pwd;
struct stat St;
...
10 years ago I was shown a technique for traversing a linked list: instead of using a single pointer, you used a double-pointer.
The technique yielded smaller, more elegant code by eliminating the need to check for certain boundary/edge cases.
Does anyone know what this technique actually is? (Trying to remember, but cannot)
...
Hey all,
Please tell me how to serialize data (like binary files) in C. And, how can i send this serialized data over sockets, so that it can be successfully received by the corresponding Java client.
Actually i want to convert this binary file into byte array so that it can be send over the sockets.
Thanks in advance.
...
Hi,
I am using C language and Linux as my programming platform. Right now I am learning some embedded programming. I am using a POS device for my practice session and my host is a Windows OS using a cygwin.
I created a simple application that will run in the target device that will read the data in the serial port and in the host side ...
Hey all,
I am working on client server architecture and i am just beginner in this thing. Here my server is of C and client is of Java and i want to send a binary/database (.db)/image file of size around 10 - 20 MB from C server to the Java client. But data is lost while implementing the following code:
Server side C code is:
int sock...