c

How can I know where the segment of memory is all Zero

I mean, I malloc a segment of memory, maybe 1k maybe 20bytes.. assume the pointer is pMem How can I know the content pMem refered is all Zero or \0 . I know memcmp but the second parameter should another memory address... thanx ...

How to get back to the same html page using cgi?

Hi, I am having C function. From the html page, through ajaxcall the request is passed and the response is got. If I perform some action like click submit button, then some action will be performed. How to get back to the same html page after redirection? Can I set the environment variable which automatically redirects me to that pag...

Is it possible to iterate over arguments in variadic macros ?

Hi, I was wondering if it is possible to iterate over arguments passed to a variadic macro in C99 or using any GCC extensions ? For e.g. is it possible to write a generic macro that takes a structure and its fields passed as arguments and prints offset of each field within the structure ? Something like this: struct a { int a; ...

Variable names in C

Hi all.. In preprocessors, we can have switch between macros like, #define BUFF(n) BUFF_##n So, BUFF(1) would get replaced by BUFF_1, BUFF(2) would get replaced by BUFF_2 and song Can this be applicable to C variables? i.e., choosing between similar variables dynamically. I understand it is a weird situation and can be handled using...

How to get a more stable socket connection in Linux/C.

I'm running a game website where users connect using an Adobe Flash client to a C server running on a Fedora Linux box. Often users complain about disconnects. Usually they're "Connection reset by peer"-disconnects. Is there any way to make the connection more stable or does it all depend on the route from the user host to my server?...

How to write a binary algorithm for C/C++

I am having trouble to write the binary algorithm in C/C++. My question is like that: Apply binary algorithm to search for a number from 1 to 100 in a number guessing game. The user will respond with 'y' for a correct guess, 'h' if the guess is too high or 'l' if the guess is too low. I don't have any idea to apply it. Can someone ju...

Identifying threads in VS .NET 2003

Hi all, I'm converting a Linux program to a Windows program using Visual Studio .NET 2003. The code was written using pthread. I have a "First-chance exception at 0x100084c8 in project.exe: 0xC0000005: Access violation reading location 0x000001dc" error that is causing my program to crash, and all but one thread "has exited with code 0...

How to convert a string pointer to a 64bit ( _int64) variable??

As I wrote an app with the function main(int argc, char * argv[]) When i start up the application, I wanna send some parameters like (assume the app name is ffdisk) >ffdisk -f 111123123131321312312123 1 You see the third param maybe an int64 param in my original intention... But in function main, argv[2] is string pointer, so how can...

How to fix this file related problem

i m reading from file line by line but when i read some garbage character like space /r is being added i m nt getting why it is being added although there is no such character in file from where i m reading ..i have used fread and fgets both from both i m getting the same problem please reply if u have solution for this problem ...

How do I convert a value from host byte order to little endian?

I need to convert a short value from the host byte order to little endian. If the target was big endian, I could use the htons() function, but alas - it's not. I guess I could do: swap(htons(val)) But this could potentially cause the bytes to be swapped twice, rendering the result correct but giving me a performance penalty which is ...

Bit operations in C

So if I have an integer that is 32 bits. The first 28 bits (from left) are to store the size of a memory chunk, the next two are 0s and the last two are: to store the if it is the last node and then to store if it is used or not (respectively). What I am trying to do is to know how to turn the flag on and off on the isLast operation ...

How to detect an invalid C escaped string using a regular expression?

I would like to find a regular expression (regex) that does detect if you have some invalid escapes in a C double quoted escaped string (where you can find double quotes only escaped). I consider valid \\ \n \r \" (the test string is using ") A partial solution to this is to use (?<!\\)\\[^\"\\nr] but this one fails to detect bad escap...

How to justify using a scripting language as part of a project

I have a specific project in which I want to use either a scripting language + C, or as an alternative a 100% Java solution. The program adapts a legacy system for use with other moderns systems. Basically, I have few choices as to what language I can use. I have C/C++, Java 1.4, and I have also compiled the Lua for this environment. ...

C/C++ J2ME interpreter

Hello, do anyone know some C or C++ interpreter for cell phones? I have Nokia 5310 and found some Basic interpreter (CellBasic) and want to develop in C or C++ on the go. Or, does anybody knows Scheme J2ME intepreter? ...

C/C++/C# Force window to be on top

Is the there a way to force another window to be on top? Not the application's window, but another one, already running on the system. (Windows, C/C++/C#) ...

C/C++/C# SetWindowPos: Window on top of others

I would like someone to give a working example of SetWindowPos on how to make a window "topmost" (be on top and stay there) using either C/C++/C#. Thanks in advance! ...

Passing an array of arrays in C

Having some serious problems wrapping my head around how to pass a 2D array to a function in C - pointers are not my strong point! I need to have a function which takes a 2D array and generates random bits, so the result is an array of random binary strings. Currently I have #define pop_size 50 #define chrom_length 50 main() { int...

How do I keep Eclipse from automatically deleting my exe file

I use Eclipse for Java development. There is an *.exe file in a subdirectory of my workspace, which keeps getting deleted. Specifically, one of the projects is dedicated to C++ development using MSVC; there is no Java there. The root of this project has cpp and h files, and I use MSVC to generate the exe under the /bin directory. A...

Filtering UDP loopback on Linux in C

Hi, I have an application bound to eth0, sending UDP packets on port A to 255.255.255.255. At the same time, I have a UDP server bound to eth0, 0.0.0.0 and port A. What I want to do is to make sure that the server won't receive messages generated by the application (handled purely in software by the kernel) but it will receive messages ...

Performance profiling on Linux

What are the best tools for profiling C/C++ applications on *nix? (I'm hoping to profile a server that is a mix of (blocking) file IO, epoll for network and fork()/execv() for some heavy lifting; but general help and more general tools are all also appreciated.) Can you get the big system picture of RAM, CPU, network and disk all in on...